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. Can be chained as well q.dot.dot.

len(list)

list → number

The number of elements in the list.

list(number, ...)

number → lane

Marks numbers as one value rather than a sequence. A lane is read by note — the nth note takes the nth value, wrapping — so div: [2, 3] gives the first note 2 and the second 3, where div: list(2, 3) gives every note both. '[2, 3] is the same value written short. Only a lane reads one.

fn poly(n, div = [4]) = for d in div { saw(n * d) * 0.3 }

play([110, 165], poly, div: list(2, 3))

The quote spelling is the one to reach for inside a lane that is already bracket-heavy:

play([110, 165], poly, div: ['[2, 3], '[4], `])

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.

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.

stack(pattern, ...)

pattern → pattern

Creates patterns that sound at once instead of in turn: stack([c4;2, e4;2], [g4;4]). Each argument keeps its own division, so the layers need not agree on a rhythm. Creates chords and polyphony.

sum(list)

list → any

Add every element together.

Weighted random choice 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.

19names in Lists. All categories.