updated names + snapshot

This commit is contained in:
Dsm0
2025-09-14 02:21:25 -07:00
parent f5c4373f99
commit addb6db1c7
2 changed files with 68 additions and 9 deletions
+10 -9
View File
@@ -2408,9 +2408,9 @@ export const applyN = register('applyN', function (n, func, p) {
});
/**
* The plyWithClassic function repeats each event the given number of times, applying the given function to each event.\n
* Here the function does not take the iteration index as an argument.
* @name plyWithClassic
* The plyWith function repeats each event the given number of times, applying the given function to each event.\n
* @name plyWith
* @synonyms plywith
* @param {number} factor how many times to repeat
* @param {function} func function to apply, given the pattern
* @example
@@ -2418,7 +2418,7 @@ export const applyN = register('applyN', function (n, func, p) {
* .plyWith(4, (p) => p.add(2))
* .scale("C:minor").note()
*/
export const plyWithClassic = register('plyWithClassic', function (factor, func, pat) {
export const plyWith = register(['plyWith', 'plywith'], function (factor, func, pat) {
const result = pat
.fmap((x) => cat(...listRange(0, factor - 1).map((i) => applyN(i, func, x)))._fast(factor))
.squeezeJoin();
@@ -2429,17 +2429,18 @@ export const plyWithClassic = register('plyWithClassic', function (factor, func,
});
/**
* The plyWith function repeats each event the given number of times, applying the given function to each event.
* @name plyWith
* @synonyms plywith
* The plyForEach function repeats each event the given number of times, applying the given function to each event.
* This version of ply uses the iteration index as an argument to the function, similar to echoWith.
* @name plyForEach
* @synonyms plyforeach
* @param {number} factor how many times to repeat
* @param {function} func function to apply, given the pattern and the iteration index
* @example
* "<0 [2 4]>"
* .plyWith(4, (p,n) => p.add(n*2))
* .plyForEach(4, (p,n) => p.add(n*2))
* .scale("C:minor").note()
*/
export const plyWith = register(['plyWith', 'plywith'], function (factor, func, pat) {
export const plyForEach = register(['plyForEach', 'plyforeach'], function (factor, func, pat) {
const result = pat
.fmap((x) => cat(cat(pure(x), ...listRange(1, factor - 1).map((i) => func(pure(x), i))))._fast(factor))
.squeezeJoin();
+58
View File
@@ -7365,6 +7365,64 @@ exports[`runs examples > example "ply" example index 0 1`] = `
]
`;
exports[`runs examples > example "plyForEach" example index 0 1`] = `
[
"[ 0/1 → 1/4 | note:C3 ]",
"[ 1/4 → 1/2 | note:Eb3 ]",
"[ 1/2 → 3/4 | note:G3 ]",
"[ 3/4 → 1/1 | note:Bb3 ]",
"[ 1/1 → 9/8 | note:Eb3 ]",
"[ 9/8 → 5/4 | note:G3 ]",
"[ 5/4 → 11/8 | note:Bb3 ]",
"[ 11/8 → 3/2 | note:D4 ]",
"[ 3/2 → 13/8 | note:G3 ]",
"[ 13/8 → 7/4 | note:Bb3 ]",
"[ 7/4 → 15/8 | note:D4 ]",
"[ 15/8 → 2/1 | note:F4 ]",
"[ 2/1 → 9/4 | note:C3 ]",
"[ 9/4 → 5/2 | note:Eb3 ]",
"[ 5/2 → 11/4 | note:G3 ]",
"[ 11/4 → 3/1 | note:Bb3 ]",
"[ 3/1 → 25/8 | note:Eb3 ]",
"[ 25/8 → 13/4 | note:G3 ]",
"[ 13/4 → 27/8 | note:Bb3 ]",
"[ 27/8 → 7/2 | note:D4 ]",
"[ 7/2 → 29/8 | note:G3 ]",
"[ 29/8 → 15/4 | note:Bb3 ]",
"[ 15/4 → 31/8 | note:D4 ]",
"[ 31/8 → 4/1 | note:F4 ]",
]
`;
exports[`runs examples > example "plyWith" example index 0 1`] = `
[
"[ 0/1 → 1/4 | note:C3 ]",
"[ 1/4 → 1/2 | note:Eb3 ]",
"[ 1/2 → 3/4 | note:G3 ]",
"[ 3/4 → 1/1 | note:Bb3 ]",
"[ 1/1 → 9/8 | note:Eb3 ]",
"[ 9/8 → 5/4 | note:G3 ]",
"[ 5/4 → 11/8 | note:Bb3 ]",
"[ 11/8 → 3/2 | note:D4 ]",
"[ 3/2 → 13/8 | note:G3 ]",
"[ 13/8 → 7/4 | note:Bb3 ]",
"[ 7/4 → 15/8 | note:D4 ]",
"[ 15/8 → 2/1 | note:F4 ]",
"[ 2/1 → 9/4 | note:C3 ]",
"[ 9/4 → 5/2 | note:Eb3 ]",
"[ 5/2 → 11/4 | note:G3 ]",
"[ 11/4 → 3/1 | note:Bb3 ]",
"[ 3/1 → 25/8 | note:Eb3 ]",
"[ 25/8 → 13/4 | note:G3 ]",
"[ 13/4 → 27/8 | note:Bb3 ]",
"[ 27/8 → 7/2 | note:D4 ]",
"[ 7/2 → 29/8 | note:G3 ]",
"[ 29/8 → 15/4 | note:Bb3 ]",
"[ 15/4 → 31/8 | note:D4 ]",
"[ 31/8 → 4/1 | note:F4 ]",
]
`;
exports[`runs examples > example "polymeter" example index 0 1`] = `
[
"[ 0/1 → 1/6 | note:c ]",