Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define and use MAPCAT; support multiple return values #203

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
693 changes: 338 additions & 355 deletions bin/compiler.js

Large diffs are not rendered by default.

635 changes: 316 additions & 319 deletions bin/compiler.lua

Large diffs are not rendered by default.

142 changes: 79 additions & 63 deletions bin/lumen.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,23 @@ map = function (f, x) {
}
return __t1;
};
mapcat = function (f, x, sep) {
var __s = "";
var __sep = sep || "";
var __c = "";
var ____x7 = x;
var ____i11 = 0;
while (____i11 < _35(____x7)) {
var __v5 = ____x7[____i11];
var __y4 = f(__v5);
if (is63(__y4)) {
__s = __s + __c + __y4;
__c = __sep;
}
____i11 = ____i11 + 1;
}
return __s;
};
keep = function (f, x) {
return map(function (v) {
if (yes(f(v))) {
Expand All @@ -320,7 +337,7 @@ keys63 = function (t) {
var ____o5 = t;
var __k8 = undefined;
for (__k8 in ____o5) {
var __v5 = ____o5[__k8];
var __v6 = ____o5[__k8];
var __e8 = undefined;
if (numeric63(__k8)) {
__e8 = parseInt(__k8);
Expand All @@ -336,16 +353,16 @@ keys63 = function (t) {
};
empty63 = function (t) {
var ____o6 = t;
var ____i12 = undefined;
for (____i12 in ____o6) {
var __x7 = ____o6[____i12];
var ____i13 = undefined;
for (____i13 in ____o6) {
var __x8 = ____o6[____i13];
var __e9 = undefined;
if (numeric63(____i12)) {
__e9 = parseInt(____i12);
if (numeric63(____i13)) {
__e9 = parseInt(____i13);
} else {
__e9 = ____i12;
__e9 = ____i13;
}
var ____i121 = __e9;
var ____i131 = __e9;
return false;
}
return true;
Expand All @@ -356,7 +373,7 @@ stash = function (args) {
var ____o7 = args;
var __k10 = undefined;
for (__k10 in ____o7) {
var __v6 = ____o7[__k10];
var __v7 = ____o7[__k10];
var __e10 = undefined;
if (numeric63(__k10)) {
__e10 = parseInt(__k10);
Expand All @@ -365,7 +382,7 @@ stash = function (args) {
}
var __k11 = __e10;
if (! number63(__k11)) {
__p[__k11] = __v6;
__p[__k11] = __v7;
}
}
__p._stash = true;
Expand All @@ -383,7 +400,7 @@ unstash = function (args) {
var ____o8 = __l2;
var __k12 = undefined;
for (__k12 in ____o8) {
var __v7 = ____o8[__k12];
var __v8 = ____o8[__k12];
var __e11 = undefined;
if (numeric63(__k12)) {
__e11 = parseInt(__k12);
Expand All @@ -392,7 +409,7 @@ unstash = function (args) {
}
var __k13 = __e11;
if (!( __k13 === "_stash")) {
__args1[__k13] = __v7;
__args1[__k13] = __v8;
}
}
return __args1;
Expand All @@ -406,7 +423,7 @@ destash33 = function (l, args1) {
var ____o9 = l;
var __k14 = undefined;
for (__k14 in ____o9) {
var __v8 = ____o9[__k14];
var __v9 = ____o9[__k14];
var __e12 = undefined;
if (numeric63(__k14)) {
__e12 = parseInt(__k14);
Expand All @@ -415,17 +432,17 @@ destash33 = function (l, args1) {
}
var __k15 = __e12;
if (!( __k15 === "_stash")) {
args1[__k15] = __v8;
args1[__k15] = __v9;
}
}
} else {
return l;
}
};
search = function (s, pattern, start) {
var __i16 = s.indexOf(pattern, start);
if (__i16 >= 0) {
return __i16;
var __i17 = s.indexOf(pattern, start);
if (__i17 >= 0) {
return __i17;
}
};
split = function (s, sep) {
Expand All @@ -435,12 +452,12 @@ split = function (s, sep) {
var __l3 = [];
var __n12 = _35(sep);
while (true) {
var __i17 = search(s, sep);
if (nil63(__i17)) {
var __i18 = search(s, sep);
if (nil63(__i18)) {
break;
} else {
add(__l3, clip(s, 0, __i17));
s = clip(s, __i17 + __n12);
add(__l3, clip(s, 0, __i18));
s = clip(s, __i18 + __n12);
}
}
add(__l3, s);
Expand Down Expand Up @@ -484,14 +501,14 @@ _37 = function () {
}, reverse(__xs5)), 0);
};
var pairwise = function (f, xs) {
var __i18 = 0;
while (__i18 < edge(xs)) {
var __a = xs[__i18];
var __b = xs[__i18 + 1];
var __i19 = 0;
while (__i19 < edge(xs)) {
var __a = xs[__i19];
var __b = xs[__i19 + 1];
if (! f(__a, __b)) {
return false;
}
__i18 = __i18 + 1;
__i19 = __i19 + 1;
}
return true;
};
Expand Down Expand Up @@ -536,12 +553,12 @@ number_code63 = function (n) {
};
numeric63 = function (s) {
var __n14 = _35(s);
var __i19 = 0;
while (__i19 < __n14) {
if (! number_code63(code(s, __i19))) {
var __i20 = 0;
while (__i20 < __n14) {
if (! number_code63(code(s, __i20))) {
return false;
}
__i19 = __i19 + 1;
__i20 = __i20 + 1;
}
return some63(s);
};
Expand All @@ -550,36 +567,36 @@ var tostring = function (x) {
};
escape = function (s) {
var __s1 = "\"";
var __i20 = 0;
while (__i20 < _35(s)) {
var __c = char(s, __i20);
var __i21 = 0;
while (__i21 < _35(s)) {
var __c1 = char(s, __i21);
var __e13 = undefined;
if (__c === "\n") {
if (__c1 === "\n") {
__e13 = "\\n";
} else {
var __e14 = undefined;
if (__c === "\r") {
if (__c1 === "\r") {
__e14 = "\\r";
} else {
var __e15 = undefined;
if (__c === "\"") {
if (__c1 === "\"") {
__e15 = "\\\"";
} else {
var __e16 = undefined;
if (__c === "\\") {
if (__c1 === "\\") {
__e16 = "\\\\";
} else {
__e16 = __c;
__e16 = __c1;
}
__e15 = __e16;
}
__e14 = __e15;
}
__e13 = __e14;
}
var __c1 = __e13;
__s1 = __s1 + __c1;
__i20 = __i20 + 1;
var __c11 = __e13;
__s1 = __s1 + __c11;
__i21 = __i21 + 1;
}
return __s1 + "\"";
};
Expand Down Expand Up @@ -618,7 +635,7 @@ str = function (x, stack) {
if (false) {
return escape(tostring(x));
} else {
var __s = "(";
var __s11 = "(";
var __sp = "";
var __xs11 = [];
var __ks = [];
Expand All @@ -627,7 +644,7 @@ str = function (x, stack) {
var ____o10 = x;
var __k16 = undefined;
for (__k16 in ____o10) {
var __v9 = ____o10[__k16];
var __v10 = ____o10[__k16];
var __e17 = undefined;
if (numeric63(__k16)) {
__e17 = parseInt(__k16);
Expand All @@ -636,28 +653,28 @@ str = function (x, stack) {
}
var __k17 = __e17;
if (number63(__k17)) {
__xs11[__k17] = str(__v9, __l4);
__xs11[__k17] = str(__v10, __l4);
} else {
add(__ks, __k17 + ":");
add(__ks, str(__v9, __l4));
add(__ks, str(__v10, __l4));
}
}
drop(__l4);
var ____o11 = join(__xs11, __ks);
var ____i22 = undefined;
for (____i22 in ____o11) {
var __v10 = ____o11[____i22];
var ____i23 = undefined;
for (____i23 in ____o11) {
var __v11 = ____o11[____i23];
var __e18 = undefined;
if (numeric63(____i22)) {
__e18 = parseInt(____i22);
if (numeric63(____i23)) {
__e18 = parseInt(____i23);
} else {
__e18 = ____i22;
__e18 = ____i23;
}
var ____i221 = __e18;
__s = __s + __sp + __v10;
var ____i231 = __e18;
__s11 = __s11 + __sp + __v11;
__sp = " ";
}
return __s + ")";
return __s11 + ")";
}
}
}
Expand All @@ -674,16 +691,16 @@ apply = function (f, args) {
return f.apply(f, __args);
};
call = function (f) {
var ____r75 = unstash(Array.prototype.slice.call(arguments, 1));
var __f = destash33(f, ____r75);
var ____id = ____r75;
var ____r76 = unstash(Array.prototype.slice.call(arguments, 1));
var __f = destash33(f, ____r76);
var ____id = ____r76;
var __args11 = cut(____id, 0);
return apply(__f, __args11);
};
setenv = function (k) {
var ____r76 = unstash(Array.prototype.slice.call(arguments, 1));
var __k18 = destash33(k, ____r76);
var ____id1 = ____r76;
var ____r77 = unstash(Array.prototype.slice.call(arguments, 1));
var __k18 = destash33(k, ____r77);
var ____id1 = ____r77;
var __keys = cut(____id1, 0);
if (string63(__k18)) {
var __e19 = undefined;
Expand All @@ -697,15 +714,15 @@ setenv = function (k) {
var ____o12 = __keys;
var __k19 = undefined;
for (__k19 in ____o12) {
var __v11 = ____o12[__k19];
var __v12 = ____o12[__k19];
var __e20 = undefined;
if (numeric63(__k19)) {
__e20 = parseInt(__k19);
} else {
__e20 = __k19;
}
var __k20 = __e20;
__entry[__k20] = __v11;
__entry[__k20] = __v12;
}
__frame[__k18] = __entry;
return __frame[__k18];
Expand Down Expand Up @@ -945,7 +962,6 @@ setenv("define", {_stash: true, macro: function (name, x) {
var __x131 = destash33(x, ____r37);
var ____id31 = ____r37;
var __body21 = cut(____id31, 0);
setenv(__name5, {_stash: true, variable: true});
if (some63(__body21)) {
return join(["%local-function", __name5], bind42(__x131, __body21));
} else {
Expand Down
Loading