Function summary | |
---|---|
circle-repeat | pattern n |
insert-at-position | position item list &key seed |
keyword-to-om-symbol | key |
mapcar-nested | fn &rest nested-lists |
matrix-transpose* | &rest lists |
A simplified equivalent of mapcar, but expects nested lists (as common for OMN parameter lists). All lists in nested-lists must be nested equally.
(mapcar-nested #'(lambda (x) (* x 2)) '((1/4 1/8 1/8) (1/2))) => ((1/2 1/4 1/4) (1))
Using the built-in Opusmodus function `span' to ensure an equal nesting of value lists
(let* ((ls '((1/4 1/8 1/8) (1/2))) (factors (span ls '(2 3)))) (mapcar-nested #'* ls factors)) => ((1/2 3/8 1/4) (3/2))
Variant of matrix-transpose that is more allowing in terms of its input. The function performs a matrix transformation, but input lists can be of different length (shorter lists are then circled through) or even mere elements (internally turned into a list by repeating the element).
lists: individual elements or lists
(matrix-transpose* '(0 1 2 3) 5) => ((0 5) (1 5) (2 5) (3 5))
(matrix-transpose* '(0 1 2 3) '(a b) '_) => ((0 a _) (1 b _) (2 a _) (3 b _))
Circle through elements in pattern (a list) until n elements are collected.
NOTE: only supports flat list so far.
pattern: a list or single value treated as a one-value list
n: an integer
(circle-repeat '(bb4 g4) 10) => (bb4 g4 bb4 g4 bb4 g4 bb4 g4 bb4 g4)
The function span can do something very similar.
(span (gen-repeat 10 'x) '(bb4 g4))
See also Opusmodus buildin gen-trim, which does the same, but is overall more flexible.
Insert item(s) at given position into list.
position: either symbol 's (start), 'e (end) or '? (random position), or integer specifying position.
item: value or list of values to be inserted.
list: flat list of values.
(insert-at-position 'e 'x '(a a a a)) (insert-at-position 's 'x '(a a a a)) (insert-at-position '? 'x '(a a a a)) (insert-at-position 'e '(x y) '(a a a a)) (insert-at-position '0 '(x y) '(a a a a))