From f33db5f07f491278995d994b84f06abf3c3c34e0 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Tue, 7 Oct 2025 22:35:29 +0200 Subject: [PATCH] - refactor bjork -> bjorklund - refactor e -> bjork - flip & desugared arguments --- packages/core/euclid.mjs | 14 +++++++------- packages/mondo/mondo.mjs | 2 +- packages/mondough/mondough.mjs | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/core/euclid.mjs b/packages/core/euclid.mjs index 44ab07f11..98c21a116 100644 --- a/packages/core/euclid.mjs +++ b/packages/core/euclid.mjs @@ -35,18 +35,18 @@ const right = function (n, x) { return result; }; -const _bjork = function (n, x) { +const _bjorklund = function (n, x) { const [ons, offs] = n; - return Math.min(ons, offs) <= 1 ? [n, x] : _bjork(...(ons > offs ? left(n, x) : right(n, x))); + return Math.min(ons, offs) <= 1 ? [n, x] : _bjorklund(...(ons > offs ? left(n, x) : right(n, x))); }; -export const bjork = function (ons, steps) { +export const bjorklund = function (ons, steps) { const inverted = ons < 0; const absOns = Math.abs(ons); const offs = steps - absOns; const ones = Array(absOns).fill([1]); const zeros = Array(offs).fill([0]); - const result = _bjork([absOns, offs], [ones, zeros]); + const result = _bjorklund([absOns, offs], [ones, zeros]); const pattern = flatten(result[1][0]).concat(flatten(result[1][1])); return inverted ? pattern.map((x) => 1 - x) : pattern; }; @@ -128,7 +128,7 @@ export const bjork = function (ons, steps) { */ const _euclidRot = function (pulses, steps, rotation) { - const b = bjork(pulses, steps); + const b = bjorklund(pulses, steps); if (rotation) { return rotate(b, -rotation); } @@ -139,7 +139,7 @@ export const euclid = register('euclid', function (pulses, steps, pat) { return pat.struct(_euclidRot(pulses, steps, 0)); }); -export const e = register('e', function (euc, pat) { +export const bjork = register('bjork', function (euc, pat) { if (!Array.isArray(euc)) { euc = [euc]; } @@ -216,6 +216,6 @@ export const euclidLegatoRot = register(['euclidLegatoRot'], function (pulses, s * .pan(sine.slow(8)) */ export const { euclidish, eish } = register(['euclidish', 'eish'], function (pulses, steps, perc, pat) { - const morphed = _morph(bjork(pulses, steps), new Array(pulses).fill(1), perc); + const morphed = _morph(bjorklund(pulses, steps), new Array(pulses).fill(1), perc); return pat.struct(morphed).setSteps(steps); }); diff --git a/packages/mondo/mondo.mjs b/packages/mondo/mondo.mjs index cdd758431..d419eaff4 100644 --- a/packages/mondo/mondo.mjs +++ b/packages/mondo/mondo.mjs @@ -165,7 +165,7 @@ export class MondoParser { const op = { type: 'plain', value: children[opIndex].value }; const left = children[opIndex - 1]; const right = children[opIndex + 1]; - const call = { type: 'list', children: [op, left, right] }; + const call = { type: 'list', children: [op, right, left] }; // insert call while keeping other siblings children = [...children.slice(0, opIndex - 1), call, ...children.slice(opIndex + 2)]; children = this.unwrap_children(children); diff --git a/packages/mondough/mondough.mjs b/packages/mondough/mondough.mjs index a299c9a55..9b1edb5a5 100644 --- a/packages/mondough/mondough.mjs +++ b/packages/mondough/mondough.mjs @@ -11,7 +11,7 @@ import { chooseIn, degradeBy, silence, - e, + bjork, } from '@strudel/core'; import { registerLanguage } from '@strudel/transpiler'; import { MondoRunner } from 'mondolang'; @@ -41,7 +41,7 @@ lib['!'] = extend; lib['@'] = expand; lib['%'] = pace; lib['?'] = degradeBy; // todo: default 0.5 not working.. -lib['&'] = (a, b) => a.e(b); +lib['&'] = bjork; lib[':'] = tail; lib['..'] = range; lib['def'] = () => silence;