pick, pickmod, inhabit, inhabitmod (#921)

* the args for `pick` are now reversed as standard (old behaviour still supported to avoid breaking change)
* `pick` is also now a pattern method
* `pick` now also accepts a lookup table for pick-by-name as an alternative to pick-by-index from a list
* `inhabit` added with same behaviour as `pick`, except cycles from source patterns are squeezed into events of inhabited patterns
* Also some general doc tidying, sorry for the noise..
* There is also `pickmod` and `inhabitmod`, for wrapping indexes around rather than clamping them
This commit is contained in:
Alex McLean 2024-01-18 17:08:29 +00:00 committed by GitHub
parent a8db707440
commit 98b7859605
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 263 additions and 46 deletions

View file

@ -2408,6 +2408,40 @@ exports[`runs examples > example "hush" example index 0 1`] = `
]
`;
exports[`runs examples > example "inhabit" example index 0 1`] = `
[
"[ 0/1 → 1/8 | s:bd ]",
"[ 3/8 → 1/2 | s:bd ]",
"[ 3/4 → 7/8 | s:bd ]",
"[ 1/1 → 3/2 | s:cp ]",
"[ 3/2 → 2/1 | s:sd ]",
"[ 2/1 → 17/8 | s:bd ]",
"[ 2/1 → 5/2 | s:cp ]",
"[ 19/8 → 5/2 | s:bd ]",
"[ 5/2 → 3/1 | s:sd ]",
"[ 11/4 → 23/8 | s:bd ]",
"[ 3/1 → 25/8 | s:bd ]",
"[ 27/8 → 7/2 | s:bd ]",
"[ 15/4 → 31/8 | s:bd ]",
]
`;
exports[`runs examples > example "inhabit" example index 1 1`] = `
[
"[ 0/1 → 1/4 | s:bd ]",
"[ 3/4 → 1/1 | s:bd ]",
"[ 3/2 → 7/4 | s:bd ]",
"[ 2/1 → 33/16 | s:bd ]",
"[ 35/16 → 9/4 | s:bd ]",
"[ 19/8 → 39/16 | s:bd ]",
"[ 5/2 → 11/4 | s:sd ]",
"[ 11/4 → 3/1 | s:sd ]",
"[ 3/1 → 25/8 | s:bd ]",
"[ 27/8 → 7/2 | s:bd ]",
"[ 15/4 → 31/8 | s:bd ]",
]
`;
exports[`runs examples > example "inside" example index 0 1`] = `
[
"[ 0/1 → 1/8 | note:D3 ]",
@ -3601,10 +3635,61 @@ exports[`runs examples > example "pick" example index 0 1`] = `
"[ 9/4 → 5/2 | note:g ]",
"[ 5/2 → 11/4 | note:f ]",
"[ 11/4 → 3/1 | note:g ]",
"[ 3/1 → 13/4 | note:g ]",
"[ 13/4 → 7/2 | note:a ]",
"[ 7/2 → 15/4 | note:c ]",
"[ 15/4 → 4/1 | note:d ]",
"[ 3/1 → 13/4 | note:f ]",
"[ 13/4 → 7/2 | note:g ]",
"[ 7/2 → 15/4 | note:f ]",
"[ 15/4 → 4/1 | note:g ]",
]
`;
exports[`runs examples > example "pick" example index 1 1`] = `
[
"[ 0/1 → 1/2 | s:bd ]",
"[ 1/2 → 1/1 | s:sd ]",
"[ 1/1 → 3/2 | s:cp ]",
"[ 3/2 → 2/1 | s:cp ]",
"[ 2/1 → 5/2 | s:hh ]",
"[ 2/1 → 5/2 | s:bd ]",
"[ 5/2 → 3/1 | s:hh ]",
"[ 5/2 → 3/1 | s:sd ]",
"[ 3/1 → 7/2 | s:bd ]",
"[ 7/2 → 4/1 | s:sd ]",
]
`;
exports[`runs examples > example "pick" example index 2 1`] = `
[
"[ 0/1 → 1/8 | s:bd ]",
"[ 3/8 → 1/2 | s:bd ]",
"[ 3/4 → 7/8 | s:bd ]",
"[ 1/1 → 9/8 | s:bd ]",
"[ 11/8 → 3/2 | s:bd ]",
"[ 7/4 → 15/8 | s:bd ]",
"[ 2/1 → 17/8 | s:bd ]",
"[ 2/1 → 5/2 | s:sd ]",
"[ 19/8 → 5/2 | s:bd ]",
"[ 5/2 → 3/1 | s:sd ]",
"[ 11/4 → 23/8 | s:bd ]",
"[ 3/1 → 7/2 | s:sd ]",
"[ 7/2 → 4/1 | s:sd ]",
]
`;
exports[`runs examples > example "pick" example index 3 1`] = `
[
"[ 0/1 → 1/8 | s:bd ]",
"[ 3/8 → 1/2 | s:bd ]",
"[ 3/4 → 7/8 | s:bd ]",
"[ 1/1 → 9/8 | s:bd ]",
"[ 11/8 → 3/2 | s:bd ]",
"[ 7/4 → 15/8 | s:bd ]",
"[ 2/1 → 17/8 | s:bd ]",
"[ 2/1 → 5/2 | s:sd ]",
"[ 19/8 → 5/2 | s:bd ]",
"[ 5/2 → 3/1 | s:sd ]",
"[ 11/4 → 23/8 | s:bd ]",
"[ 3/1 → 7/2 | s:sd ]",
"[ 7/2 → 4/1 | s:sd ]",
]
`;