mirror of
https://codeberg.org/uzu/strudel
synced 2026-09-05 14:58:03 -04:00
failed attempt at composifying
This commit is contained in:
@@ -819,7 +819,15 @@ const _setter = (func, name) =>
|
||||
};
|
||||
|
||||
generic_params.forEach(([type, name, description]) => {
|
||||
controls[name] = (...pats) => _name(name, ...pats);
|
||||
controls[name] = function (...pats) {
|
||||
const result = _name(name, ...pats);
|
||||
|
||||
// Add a function for composing this control with another pattern
|
||||
result.__compose = function (pat) {
|
||||
return pat[name](...pats);
|
||||
};
|
||||
return result;
|
||||
};
|
||||
Pattern.prototype[name] = _setter(controls[name], name);
|
||||
});
|
||||
|
||||
|
||||
@@ -1569,6 +1569,13 @@ export const outside = register('outside', function (factor, f, pat) {
|
||||
*/
|
||||
export const lastOf = register('lastOf', function (n, func, pat) {
|
||||
const pats = Array(n - 1).fill(pat);
|
||||
|
||||
// It seems we have a pattern, but with a 'compose' function, let's
|
||||
// use that
|
||||
if ('__compose' in func) {
|
||||
func = func.__compose;
|
||||
}
|
||||
|
||||
pats.push(func(pat));
|
||||
return slowcatPrime(...pats);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user