diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index b94198f3..fec26804 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -809,15 +809,6 @@ export class Pattern { ////////////////////////////////////////////////////////////////////// // Multi-pattern functions - /** - * Stacks the given pattern(s) to the current pattern. - * @name stack - * @memberof Pattern - * @example - * s("hh*4").stack( - * note("c4(5,8)") - * ) - */ stack(...pats) { return stack(this, ...pats); } @@ -826,30 +817,9 @@ export class Pattern { return sequence(this, ...pats); } - /** - * Appends the given pattern(s) to the current pattern. - * @name seq - * @memberof Pattern - * @synonyms sequence, fastcat - * @example - * s("hh*4").seq( - * note("c4(5,8)") - * ) - */ seq(...pats) { return sequence(this, ...pats); } - - /** - * Appends the given pattern(s) to the next cycle. - * @name cat - * @memberof Pattern - * @synonyms slowcat - * @example - * s("hh*4").cat( - * note("c4(5,8)") - * ) - */ cat(...pats) { return cat(this, ...pats); } @@ -1280,6 +1250,12 @@ export function reify(thing) { * @example * stack("g3", "b3", ["e4", "d4"]).note() * // "g3,b3,[e4,d4]".note() + * + * @example + * // As a chained function: + * s("hh*4").stack( + * note("c4(5,8)") + * ) */ export function stack(...pats) { // Array test here is to avoid infinite recursions.. @@ -1408,6 +1384,11 @@ export function slowcatPrime(...pats) { * cat("e5", "b4", ["d5", "c5"]).note() * // "".note() * + * @example + * // As a chained function: + * s("hh*4").cat( + * note("c4(5,8)") + * ) */ export function cat(...pats) { return slowcat(...pats); @@ -1478,12 +1459,18 @@ export function sequence(...pats) { } /** Like **cat**, but the items are crammed into one cycle. - * @synonyms fastcat, sequence + * @synonyms sequence, fastcat * @example * seq("e5", "b4", ["d5", "c5"]).note() * // "e5 b4 [d5 c5]".note() * + * @example + * // As a chained function: + * s("hh*4").seq( + * note("c4(5,8)") + * ) */ + export function seq(...pats) { return fastcat(...pats); } diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index a74987d9..a3419e98 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -1379,6 +1379,16 @@ exports[`runs examples > example "brandBy" example index 0 1`] = ` `; exports[`runs examples > example "cat" example index 0 1`] = ` +[ + "[ 0/1 → 1/1 | note:e5 ]", + "[ 1/1 → 2/1 | note:b4 ]", + "[ 2/1 → 5/2 | note:d5 ]", + "[ 5/2 → 3/1 | note:c5 ]", + "[ 3/1 → 4/1 | note:e5 ]", +] +`; + +exports[`runs examples > example "cat" example index 1 1`] = ` [ "[ 0/1 → 1/4 | s:hh ]", "[ 1/4 → 1/2 | s:hh ]", @@ -1401,16 +1411,6 @@ exports[`runs examples > example "cat" example index 0 1`] = ` ] `; -exports[`runs examples > example "cat" example index 0 2`] = ` -[ - "[ 0/1 → 1/1 | note:e5 ]", - "[ 1/1 → 2/1 | note:b4 ]", - "[ 2/1 → 5/2 | note:d5 ]", - "[ 5/2 → 3/1 | note:c5 ]", - "[ 3/1 → 4/1 | note:e5 ]", -] -`; - exports[`runs examples > example "ceil" example index 0 1`] = ` [ "[ 0/1 → 1/4 | note:42 ]", @@ -6976,6 +6976,27 @@ exports[`runs examples > example "segment" example index 0 1`] = ` `; exports[`runs examples > example "seq" example index 0 1`] = ` +[ + "[ 0/1 → 1/3 | note:e5 ]", + "[ 1/3 → 2/3 | note:b4 ]", + "[ 2/3 → 5/6 | note:d5 ]", + "[ 5/6 → 1/1 | note:c5 ]", + "[ 1/1 → 4/3 | note:e5 ]", + "[ 4/3 → 5/3 | note:b4 ]", + "[ 5/3 → 11/6 | note:d5 ]", + "[ 11/6 → 2/1 | note:c5 ]", + "[ 2/1 → 7/3 | note:e5 ]", + "[ 7/3 → 8/3 | note:b4 ]", + "[ 8/3 → 17/6 | note:d5 ]", + "[ 17/6 → 3/1 | note:c5 ]", + "[ 3/1 → 10/3 | note:e5 ]", + "[ 10/3 → 11/3 | note:b4 ]", + "[ 11/3 → 23/6 | note:d5 ]", + "[ 23/6 → 4/1 | note:c5 ]", +] +`; + +exports[`runs examples > example "seq" example index 1 1`] = ` [ "[ 0/1 → 1/8 | s:hh ]", "[ 1/8 → 1/4 | s:hh ]", @@ -7016,27 +7037,6 @@ exports[`runs examples > example "seq" example index 0 1`] = ` ] `; -exports[`runs examples > example "seq" example index 0 2`] = ` -[ - "[ 0/1 → 1/3 | note:e5 ]", - "[ 1/3 → 2/3 | note:b4 ]", - "[ 2/3 → 5/6 | note:d5 ]", - "[ 5/6 → 1/1 | note:c5 ]", - "[ 1/1 → 4/3 | note:e5 ]", - "[ 4/3 → 5/3 | note:b4 ]", - "[ 5/3 → 11/6 | note:d5 ]", - "[ 11/6 → 2/1 | note:c5 ]", - "[ 2/1 → 7/3 | note:e5 ]", - "[ 7/3 → 8/3 | note:b4 ]", - "[ 8/3 → 17/6 | note:d5 ]", - "[ 17/6 → 3/1 | note:c5 ]", - "[ 3/1 → 10/3 | note:e5 ]", - "[ 10/3 → 11/3 | note:b4 ]", - "[ 11/3 → 23/6 | note:d5 ]", - "[ 23/6 → 4/1 | note:c5 ]", -] -`; - exports[`runs examples > example "seqPLoop" example index 0 1`] = ` [ "[ 0/1 → 1/8 | s:bd ]", @@ -7730,6 +7730,27 @@ exports[`runs examples > example "squiz" example index 0 1`] = ` `; exports[`runs examples > example "stack" example index 0 1`] = ` +[ + "[ 0/1 → 1/2 | note:e4 ]", + "[ 0/1 → 1/1 | note:g3 ]", + "[ 0/1 → 1/1 | note:b3 ]", + "[ 1/2 → 1/1 | note:d4 ]", + "[ 1/1 → 3/2 | note:e4 ]", + "[ 1/1 → 2/1 | note:g3 ]", + "[ 1/1 → 2/1 | note:b3 ]", + "[ 3/2 → 2/1 | note:d4 ]", + "[ 2/1 → 5/2 | note:e4 ]", + "[ 2/1 → 3/1 | note:g3 ]", + "[ 2/1 → 3/1 | note:b3 ]", + "[ 5/2 → 3/1 | note:d4 ]", + "[ 3/1 → 7/2 | note:e4 ]", + "[ 3/1 → 4/1 | note:g3 ]", + "[ 3/1 → 4/1 | note:b3 ]", + "[ 7/2 → 4/1 | note:d4 ]", +] +`; + +exports[`runs examples > example "stack" example index 1 1`] = ` [ "[ 0/1 → 1/8 | note:c4 ]", "[ 0/1 → 1/4 | s:hh ]", @@ -7770,27 +7791,6 @@ exports[`runs examples > example "stack" example index 0 1`] = ` ] `; -exports[`runs examples > example "stack" example index 0 2`] = ` -[ - "[ 0/1 → 1/2 | note:e4 ]", - "[ 0/1 → 1/1 | note:g3 ]", - "[ 0/1 → 1/1 | note:b3 ]", - "[ 1/2 → 1/1 | note:d4 ]", - "[ 1/1 → 3/2 | note:e4 ]", - "[ 1/1 → 2/1 | note:g3 ]", - "[ 1/1 → 2/1 | note:b3 ]", - "[ 3/2 → 2/1 | note:d4 ]", - "[ 2/1 → 5/2 | note:e4 ]", - "[ 2/1 → 3/1 | note:g3 ]", - "[ 2/1 → 3/1 | note:b3 ]", - "[ 5/2 → 3/1 | note:d4 ]", - "[ 3/1 → 7/2 | note:e4 ]", - "[ 3/1 → 4/1 | note:g3 ]", - "[ 3/1 → 4/1 | note:b3 ]", - "[ 7/2 → 4/1 | note:d4 ]", -] -`; - exports[`runs examples > example "steps" example index 0 1`] = ` [ "[ 0/1 → 1/4 | s:bd ]", diff --git a/website/src/pages/learn/factories.mdx b/website/src/pages/learn/factories.mdx index a823bfed..6a2e165b 100644 --- a/website/src/pages/learn/factories.mdx +++ b/website/src/pages/learn/factories.mdx @@ -25,26 +25,14 @@ These are the equivalents used by the Mini Notation: -You can also use cat as a chained function like this: - - - ## seq -Or as a chained function: - - - ## stack -As a chained function: - - - ## s_cat