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
This commit is contained in:
Alex McLean 2025-01-14 13:39:14 +00:00 committed by GitHub
parent c5de21ef61
commit 55c226cda6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1491,6 +1491,14 @@ function _sequenceCount(x) {
export const mask = curry((a, b) => reify(b).mask(a)); export const mask = curry((a, b) => reify(b).mask(a));
export const struct = curry((a, b) => reify(b).struct(a)); export const struct = curry((a, b) => reify(b).struct(a));
export const superimpose = curry((a, b) => reify(b).superimpose(...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 // operators
export const set = curry((a, b) => reify(b).set(a)); export const set = curry((a, b) => reify(b).set(a));
@ -2539,6 +2547,10 @@ Pattern.prototype.stepJoin = function () {
return new Pattern(q, first_t); return new Pattern(q, first_t);
}; };
Pattern.prototype.stepBind = function (func) {
return this.fmap(func).stepJoin();
};
export function _retime(timedHaps) { export function _retime(timedHaps) {
const occupied_perc = timedHaps.filter((t, pat) => pat.hasTactus).reduce((a, b) => a.add(b), Fraction(0)); 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( const occupied_tactus = removeUndefineds(timedHaps.map((t, pat) => pat.tactus)).reduce(