utilities/clip [ Functions ]
Name
clip
File
utilities.lisp
Description
Returns a value if it is between min and max. Else returns min or max. If val is a list, all numbers inside of it are clipped. If val is a string, it is clipped below char min and above char max. Anything else is simply returned.
Arguments
val: the value (number or list)
Optional Arguments
min: minimum number (default: 0) max: maximum number (default: 1)
Return Value
number or list
Example
(clip 5) --> 1 (clip 5 0 5) --> 5 (clip 10 0 5) --> 5
utilities/ensure-list [ Functions ]
Name
ensure-list
File
utilities.lsp
Description
Will put the value in place into a list if it is not a list. The value will be changed in place!
Arguments
any element
Return Value
list
Example
(let ((val 1)) (ensure-list val) val) --> '(1) (let ((val '(1 2 3))) (ensure-list val) val) --> '(1 2 3)
utilities/flat [ Functions ]
Name
flat
File
utilities.lisp
Description
Flattens a list.
Arguments
ls: A list to flatten. Any other element will be returned as a one-element list (also a flat list)
Return Value
always a flat list
Example
(flat '((1 2 3 (4)))) --> (1 2 3 4)
utilities/random-between [ Functions ]
Name
random-between
File
utilities.lisp
Description
Returns a random number between min and max. If :amount is >1, a list of random numbers is returned.
Arguments
min: minimum number max: maximum number no-float: only integers if t (default: nil) amount: amount of random numbers
Return Value
float, integer or list
Example
(random-between 0 1 :amount 1 :no-float nil)
utilities/relations [ Functions ]
Name
relations
File
utilities.lisp
Description
Takes positive numbers and returns a list of numbers with equal relations to each other and a sum of 1 (= percentage)
Rest Arguments
values: positive numbers and lists of positive numbers (will be flattened)
Return Value
flat list
Example
(relations 1 9) --> (1/10 9/10)
utilities/set-length [ Functions ]
Name
set-length
File
utilities.lisp
Description
Takes a list or a single element an always returns a list of the specified length. If the original list is larger, it is cut. If the specified list is shorter, the list will be appended to itself until it matches the target-length.
Arguments
target-length ls
Return Value
list
Example
(set-length 8 '(1 2 3)) --> (1 2 3 1 2 3 1 2)
utilities/shift-value [ Functions ]
Name
shift-value
File
utilities.lisp
Description
Shifts a value in a range between min and max to its proportional equivalent in the range between tar-min and tar-max
Arguments
(all numbers) val: The value min: The current minimum max: The current maximum tar-min: The target minimum tar-max: The target maximum
Return Value
number
Example
(shift-value .5 0 1 0 100) -> 50
utilities/stretch-list [ Functions ]
Name
stretch-list
File
utilities.lisp
Description
Takes a list and stretches it to the specified length by either skipping or repeating elements.
Arguments
target-length list
Return Value
list
Example
(stretch-list 8 '(1 2 3)) --> (1 1 1 2 2 2 3 3)