From 55c226cda6aa9e30d0a7fbf0fdb7074bf1686fc4 Mon Sep 17 00:00:00 2001 From: Alex McLean Date: Tue, 14 Jan 2025 13:39:14 +0000 Subject: [PATCH] Add stepBind, and some toplevel aliases for binds and withValue (#1241) * Add toplevel withValue function * add stepBind, and add toplevel aliases for this and other binds --- packages/core/pattern.mjs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index f3f19f87..4874a35f 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -1491,6 +1491,14 @@ function _sequenceCount(x) { export const mask = curry((a, b) => reify(b).mask(a)); export const struct = curry((a, b) => reify(b).struct(a)); export const superimpose = curry((a, b) => reify(b).superimpose(...a)); +export const withValue = curry((a, b) => reify(b).withValue(a)); + +export const bind = curry((a, b) => reify(b).bind(a)); +export const innerBind = curry((a, b) => reify(b).innerBind(a)); +export const outerBind = curry((a, b) => reify(b).outerBind(a)); +export const squeezeBind = curry((a, b) => reify(b).squeezeBind(a)); +export const stepBind = curry((a, b) => reify(b).stepBind(a)); +export const polyBind = curry((a, b) => reify(b).polyBind(a)); // operators export const set = curry((a, b) => reify(b).set(a)); @@ -2539,6 +2547,10 @@ Pattern.prototype.stepJoin = function () { return new Pattern(q, first_t); }; +Pattern.prototype.stepBind = function (func) { + return this.fmap(func).stepJoin(); +}; + export function _retime(timedHaps) { const occupied_perc = timedHaps.filter((t, pat) => pat.hasTactus).reduce((a, b) => a.add(b), Fraction(0)); const occupied_tactus = removeUndefineds(timedHaps.map((t, pat) => pat.tactus)).reduce(