Function Reference

Lists

Building and reshaping lists — of notes, of steps, of anything else.

choice(list)

list → any

One element picked at random. Re-rolled on every eval.

dot(value, dots?)

duration → duration

Dot a written note value: q.dot is a dotted quarter, a quarter and an eighth. dots defaults to 1; q.dot(2) is the doubly-dotted quarter, which is a quarter and an eighth and a sixteenth. Written as a count rather than by repeating .dot, because each dot adds half of the note itself rather than half of what the last one left.

Keep the elements the predicate answers non-zero for. The predicate is an ordinary user fn of one argument.

len(list)

list → number

The number of elements in the list.

Apply a function to every element: riff.map(up). The transform is an ordinary user fn of one argument, and may answer with anything — mapping to oscillators is the only way to hold several voices apart, since a for over audio sums instead of collecting.

palindrome(list)

list → list

The list followed by its mirror: [a, b, c] becomes [a, b, c, c, b, a].

pop(list)

list → list

A new list without its last element. Index the list to read that element.

push(list, value)

list → list

A new list with value appended. Lists are immutable — the original is unchanged.

rev(list)

list → list

The list, back to front.

rotl(list, amount?)

list → list

Rotate left, wrapping. amount defaults to 1; a negative amount rotates right.

rotr(list, amount?)

list → list

Rotate right, wrapping. amount defaults to 1; a negative amount rotates left.

scramble(list)

list → list

The list shuffled. Re-rolled on every eval.

sort(list)

list → list

The list sorted ascending. Every element must be a compile-time number.

split(list, size)

list → list

Break the list into chunks of size. A short final chunk is kept.

stack(pattern, ...)

pattern → pattern

Patterns that sound at once instead of in turn: stack([c4;2, e4;2], [g4;4]) is a two-note line under a held g. Each argument keeps its own division, so the layers need not agree on a rhythm — a three against a four is written by stacking them. This is how a chord is written, and how a drawn part with overlapping notes is split into voices. Lanes read a stack as all its values in order, layer by layer.

sum(list)

list → any

Add every element together. Folds numbers at compile time and emits mixing nodes for signals, so a list of oscillators sums into the graph.

One element picked at random, weighted. The two lists run in parallel; weights must be finite and >= 0.

zip(list, ...)

list → list

Pair elements positionally: zip([1, 2], [3, 4]) is [[1, 3], [2, 4]]. Every argument must be a list, and all must be the same length.

18names in Lists. All categories.