Skip to content

Commit

Permalink
Add stepBind, and some toplevel aliases for binds and withValue (#1241)
Browse files Browse the repository at this point in the history
* Add toplevel withValue function
* add stepBind, and add toplevel aliases for this and other binds
  • Loading branch information
yaxu authored Jan 14, 2025
1 parent c5de21e commit 55c226c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/core/pattern.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 55c226c

Please sign in to comment.