Allow wchooseCycles probabilities to be patterned (#1292)

* allow wchooseCycles probabilities to be patterned
This commit is contained in:
Alex McLean 2025-02-23 09:52:27 +00:00 committed by GitHub
parent 1f233b9e7d
commit 0925ea56dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 181 additions and 8 deletions

View file

@ -1244,6 +1244,16 @@ export function reify(thing) {
return pure(thing);
}
/** Takes a list of patterns, and returns a pattern of lists.
*/
export function sequenceP(pats) {
let result = pure([]);
for (const pat of pats) {
result = result.bind((list) => pat.fmap((v) => list.concat([v])));
}
return result;
}
/** The given items are played at the same time at the same length.
*
* @return {Pattern}