support : in mondo

This commit is contained in:
Felix Roos 2025-03-19 17:03:17 +01:00
parent 88ca54461e
commit 642ddcdb59
No known key found for this signature in database
3 changed files with 37 additions and 1 deletions

View file

@ -17,7 +17,7 @@ strudelScope.leaf = (token) => {
strudelScope.call = (fn, args, name) => {
const [pat, ...rest] = args;
if (!['seq', 'cat', 'stack'].includes(name)) {
if (!['seq', 'cat', 'stack', ':'].includes(name)) {
args = [...rest, pat];
}
return fn(...args);
@ -26,6 +26,9 @@ strudelScope.call = (fn, args, name) => {
strudelScope['*'] = fast;
strudelScope['/'] = slow;
const tail = (pat, friend) => pat.fmap((a) => (b) => (Array.isArray(a) ? [...a, b] : [a, b])).appLeft(friend);
strudelScope[':'] = tail;
export function mondo(code, offset = 0) {
if (Array.isArray(code)) {
code = code.join('');