forked from sctb/lumen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.js
3914 lines (3896 loc) · 108 KB
/
lib.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var create = (globals) => {
var _G = Object.assign({}, globals || {});
_G._G = _G;
_G.environment = [{}];
var nil63 = (x) => {
return x === undefined || x === null;
};
_G.nil63 = nil63;
var is63 = (x) => {
return ! nil63(x);
};
_G.is63 = is63;
var no = (x) => {
return nil63(x) || x === false;
};
_G.no = no;
var yes = (x) => {
return ! no(x);
};
_G.yes = yes;
var either = (x, y) => {
if (is63(x)) {
return x;
} else {
return y;
}
};
_G.either = either;
var has63 = (l, k) => {
return l.hasOwnProperty(k);
};
_G.has63 = has63;
var _35 = (x) => {
var __n = x.length;
if (number63(__n)) {
return __n;
} else {
var __n1 = -1;
var ____o = x;
var __k = undefined;
for (__k in ____o) {
var __v = ____o[__k];
var __e;
if (numeric63(__k)) {
__e = parseInt(__k);
} else {
__e = __k;
}
var __k1 = __e;
if (number63(__k1) && __k1 > __n1) {
__n1 = __k1;
}
}
return __n1 + 1;
}
};
_G._35 = _35;
var none63 = (x) => {
return _35(x) === 0;
};
_G.none63 = none63;
var some63 = (x) => {
return _35(x) > 0;
};
_G.some63 = some63;
var one63 = (x) => {
return _35(x) === 1;
};
_G.one63 = one63;
var two63 = (x) => {
return _35(x) === 2;
};
_G.two63 = two63;
var hd = (l) => {
return l[0];
};
_G.hd = hd;
var type = (x) => {
return typeof(x);
};
_G.type = type;
var type63 = (x, y) => {
return type(x) === y;
};
_G.type63 = type63;
var string63 = (x) => {
return type63(x, "string");
};
_G.string63 = string63;
var number63 = (x) => {
return type63(x, "number");
};
_G.number63 = number63;
var boolean63 = (x) => {
return type63(x, "boolean");
};
_G.boolean63 = boolean63;
var function63 = (x) => {
return type63(x, "function");
};
_G.function63 = function63;
var symbol63 = (x) => {
return type63(x, "symbol");
};
_G.symbol63 = symbol63;
var obj63 = (x) => {
return is63(x) && type63(x, "object");
};
_G.obj63 = obj63;
var array63 = (x) => {
return Array.isArray(x);
};
_G.array63 = array63;
var atom63 = (x) => {
return nil63(x) || string63(x) || number63(x) || boolean63(x) || symbol63(x);
};
_G.atom63 = atom63;
var fresh = (x) => {
var ____x = type(x);
if ("object" === ____x) {
if (nil63(x)) {
return undefined;
} else {
if (array63(x)) {
return [];
} else {
return {};
}
}
} else {
if ("undefined" === ____x) {
return [];
} else {
if ("symbol" === ____x) {
return Symbol();
} else {
if ("string" === ____x) {
return "";
} else {
if ("number" === ____x) {
return 0;
}
}
}
}
}
};
_G.fresh = fresh;
nan = 0 / 0;
_G.nan = nan;
inf = 1 / 0;
_G.inf = inf;
_inf = - inf;
_G._inf = _inf;
var nan63 = (n) => {
return !( n === n);
};
_G.nan63 = nan63;
var inf63 = (n) => {
return n === inf || n === _inf;
};
_G.inf63 = inf63;
var clip = (s, from, upto) => {
return s.substring(from, upto);
};
_G.clip = clip;
var cut = (x, from, upto) => {
var __l = fresh(x);
var __j = 0;
var __e1;
if (nil63(from) || from < 0) {
__e1 = 0;
} else {
__e1 = from;
}
var __i1 = __e1;
var __n3 = _35(x);
var __e2;
if (nil63(upto) || upto > __n3) {
__e2 = __n3;
} else {
__e2 = upto;
}
var __upto = __e2;
while (__i1 < __upto) {
__l[__j] = x[__i1];
__i1 = __i1 + 1;
__j = __j + 1;
}
var ____o1 = x;
var __k2 = undefined;
for (__k2 in ____o1) {
var __v1 = ____o1[__k2];
var __e3;
if (numeric63(__k2)) {
__e3 = parseInt(__k2);
} else {
__e3 = __k2;
}
var __k3 = __e3;
if (! number63(__k3)) {
__l[__k3] = __v1;
}
}
return __l;
};
_G.cut = cut;
var keys = (x) => {
var __t = {};
var ____o2 = x;
var __k4 = undefined;
for (__k4 in ____o2) {
var __v2 = ____o2[__k4];
var __e4;
if (numeric63(__k4)) {
__e4 = parseInt(__k4);
} else {
__e4 = __k4;
}
var __k5 = __e4;
if (! number63(__k5)) {
__t[__k5] = __v2;
}
}
return __t;
};
_G.keys = keys;
var edge = (x) => {
return _35(x) - 1;
};
_G.edge = edge;
var inner = (x) => {
return clip(x, 1, edge(x));
};
_G.inner = inner;
var tl = (l) => {
return cut(l, 1);
};
_G.tl = tl;
var char = (s, n) => {
return s.charAt(n);
};
_G.char = char;
var code = (s, n) => {
return s.charCodeAt(n);
};
_G.code = code;
var stringLiteral63 = (x) => {
return string63(x) && char(x, 0) === "\"";
};
_G.stringLiteral63 = stringLiteral63;
var idLiteral63 = (x) => {
return string63(x) && char(x, 0) === "|";
};
_G.idLiteral63 = idLiteral63;
var add = (l, x) => {
if (l.push) {
l.push(x);
} else {
l[_35(l)] = x;
}
return undefined;
};
_G.add = add;
var drop = (l) => {
if (l.pop) {
return l.pop();
} else {
var __i4 = edge(l);
var __x1 = l[__i4];
delete l[__i4];
return __x1;
}
};
_G.drop = drop;
var last = (l) => {
return l[edge(l)];
};
_G.last = last;
var almost = (l) => {
return cut(l, 0, edge(l));
};
_G.almost = almost;
var reverse = (l) => {
var __l1 = fresh(l);
var __n6 = edge(l);
var ____o3 = l;
var __k6 = undefined;
for (__k6 in ____o3) {
var __v3 = ____o3[__k6];
var __e5;
if (numeric63(__k6)) {
__e5 = parseInt(__k6);
} else {
__e5 = __k6;
}
var __k7 = __e5;
if (number63(__k7)) {
__k7 = __n6 - __k7;
}
__l1[__k7] = __v3;
}
return __l1;
};
_G.reverse = reverse;
var reduce = (f, x) => {
if (none63(x)) {
return undefined;
} else {
if (one63(x)) {
return hd(x);
} else {
return f(hd(x), reduce(f, tl(x)));
}
}
};
_G.reduce = reduce;
var join = (...ls) => {
var __ls = unstash(ls);
var __r42 = fresh(hd(__ls));
var ____x2 = __ls;
var ____i6 = 0;
while (____i6 < _35(____x2)) {
var __l11 = ____x2[____i6];
if (__l11) {
var __n8 = _35(__r42);
var ____o4 = __l11;
var __k8 = undefined;
for (__k8 in ____o4) {
var __v4 = ____o4[__k8];
var __e6;
if (numeric63(__k8)) {
__e6 = parseInt(__k8);
} else {
__e6 = __k8;
}
var __k9 = __e6;
if (number63(__k9)) {
__k9 = __k9 + __n8;
}
__r42[__k9] = __v4;
}
}
____i6 = ____i6 + 1;
}
return __r42;
};
_G.join = join;
var find = (f, t) => {
var ____o5 = t;
var ____i8 = undefined;
for (____i8 in ____o5) {
var __x3 = ____o5[____i8];
var __e7;
if (numeric63(____i8)) {
__e7 = parseInt(____i8);
} else {
__e7 = ____i8;
}
var ____i81 = __e7;
var __y = f(__x3);
if (__y) {
return __y;
}
}
};
_G.find = find;
var first = (f, l) => {
var ____x4 = l;
var ____i9 = 0;
while (____i9 < _35(____x4)) {
var __x5 = ____x4[____i9];
var __y1 = f(__x5);
if (__y1) {
return __y1;
}
____i9 = ____i9 + 1;
}
};
_G.first = first;
var in63 = (x, t) => {
return find((y) => {
return x === y;
}, t);
};
_G.in63 = in63;
var pair = (l) => {
var __l12 = fresh(l);
var __i10 = 0;
while (__i10 < _35(l)) {
add(__l12, [l[__i10], l[__i10 + 1]]);
__i10 = __i10 + 1;
__i10 = __i10 + 1;
}
return __l12;
};
_G.pair = pair;
var sort = (l, f) => {
var __e8;
if (f) {
__e8 = (a, b) => {
if (f(a, b)) {
return -1;
} else {
return 1;
}
};
}
return l.sort(__e8);
};
_G.sort = sort;
var map = (f, x) => {
var __t1 = fresh(x);
var ____x6 = x;
var ____i11 = 0;
while (____i11 < _35(____x6)) {
var __v5 = ____x6[____i11];
var __y2 = f(__v5);
if (is63(__y2)) {
add(__t1, __y2);
}
____i11 = ____i11 + 1;
}
var ____o6 = x;
var __k10 = undefined;
for (__k10 in ____o6) {
var __v6 = ____o6[__k10];
var __e9;
if (numeric63(__k10)) {
__e9 = parseInt(__k10);
} else {
__e9 = __k10;
}
var __k11 = __e9;
if (! number63(__k11)) {
var __y3 = f(__v6);
if (is63(__y3)) {
__t1[__k11] = __y3;
}
}
}
return __t1;
};
_G.map = map;
var keep = (f, x) => {
return map((v) => {
if (yes(f(v))) {
return v;
}
}, x);
};
_G.keep = keep;
var keys63 = (t) => {
var ____o7 = t;
var __k12 = undefined;
for (__k12 in ____o7) {
var __v7 = ____o7[__k12];
var __e10;
if (numeric63(__k12)) {
__e10 = parseInt(__k12);
} else {
__e10 = __k12;
}
var __k13 = __e10;
if (! number63(__k13)) {
return true;
}
}
return false;
};
_G.keys63 = keys63;
var empty63 = (t) => {
var ____o8 = t;
var ____i14 = undefined;
for (____i14 in ____o8) {
var __x7 = ____o8[____i14];
var __e11;
if (numeric63(____i14)) {
__e11 = parseInt(____i14);
} else {
__e11 = ____i14;
}
var ____i141 = __e11;
return false;
}
return true;
};
_G.empty63 = empty63;
var stash = (args) => {
if (args._stash) {
return args;
} else {
if (keys63(args)) {
var __l2 = [];
var ____x8 = args;
var ____i15 = 0;
while (____i15 < _35(____x8)) {
var __x9 = ____x8[____i15];
add(__l2, __x9);
____i15 = ____i15 + 1;
}
var __p = keys(args);
__p._stash = __p._stash || true;
add(__l2, __p);
return __l2;
} else {
return args;
}
}
};
_G.stash = stash;
var unstash = (args) => {
if (none63(args)) {
return fresh(args);
} else {
var __l3 = last(args);
if (obj63(__l3) && __l3._stash) {
var __args1 = almost(args);
var ____o9 = __l3;
var __k14 = undefined;
for (__k14 in ____o9) {
var __v8 = ____o9[__k14];
var __e12;
if (numeric63(__k14)) {
__e12 = parseInt(__k14);
} else {
__e12 = __k14;
}
var __k15 = __e12;
if (!( __k15 === "_stash")) {
__args1[__k15] = __v8;
}
}
return __args1;
} else {
return args;
}
}
};
_G.unstash = unstash;
var destash33 = (l, args1) => {
if (obj63(l) && l._stash) {
var ____o10 = l;
var __k16 = undefined;
for (__k16 in ____o10) {
var __v9 = ____o10[__k16];
var __e13;
if (numeric63(__k16)) {
__e13 = parseInt(__k16);
} else {
__e13 = __k16;
}
var __k17 = __e13;
if (!( __k17 === "_stash")) {
args1[__k17] = __v9;
}
}
} else {
return l;
}
};
_G.destash33 = destash33;
var search = (s, pattern, start) => {
var __i18 = s.indexOf(pattern, start);
if (__i18 >= 0) {
return __i18;
}
};
_G.search = search;
var split = (s, sep) => {
if (s === "" || sep === "") {
return [];
} else {
var __l4 = [];
var __n16 = _35(sep);
while (true) {
var __i19 = search(s, sep);
if (nil63(__i19)) {
break;
} else {
add(__l4, clip(s, 0, __i19));
s = clip(s, __i19 + __n16);
}
}
add(__l4, s);
return __l4;
}
};
_G.split = split;
var cat = (...xs) => {
var __xs = unstash(xs);
return either(reduce((a, b) => {
return a + b;
}, __xs), "");
};
_G.cat = cat;
var _43 = (...xs) => {
var __xs1 = unstash(xs);
return either(reduce((a, b) => {
return a + b;
}, __xs1), 0);
};
_G._43 = _43;
var _45 = (...xs) => {
var __xs2 = unstash(xs);
return either(reduce((b, a) => {
return a - b;
}, reverse(__xs2)), 0);
};
_G._45 = _45;
var _42 = (...xs) => {
var __xs3 = unstash(xs);
return either(reduce((a, b) => {
return a * b;
}, __xs3), 1);
};
_G._42 = _42;
var _47 = (...xs) => {
var __xs4 = unstash(xs);
return either(reduce((b, a) => {
return a / b;
}, reverse(__xs4)), 1);
};
_G._47 = _47;
var _37 = (...xs) => {
var __xs5 = unstash(xs);
return either(reduce((b, a) => {
return a % b;
}, reverse(__xs5)), 0);
};
_G._37 = _37;
var pairwise = (f, xs) => {
var __i20 = 0;
while (__i20 < edge(xs)) {
var __a = xs[__i20];
var __b = xs[__i20 + 1];
if (! f(__a, __b)) {
return false;
}
__i20 = __i20 + 1;
}
return true;
};
_G.pairwise = pairwise;
var _60 = (...xs) => {
var __xs6 = unstash(xs);
return pairwise((a, b) => {
return a < b;
}, __xs6);
};
_G._60 = _60;
var _62 = (...xs) => {
var __xs7 = unstash(xs);
return pairwise((a, b) => {
return a > b;
}, __xs7);
};
_G._62 = _62;
var _61 = (...xs) => {
var __xs8 = unstash(xs);
return pairwise((a, b) => {
return a === b;
}, __xs8);
};
_G._61 = _61;
var _6061 = (...xs) => {
var __xs9 = unstash(xs);
return pairwise((a, b) => {
return a <= b;
}, __xs9);
};
_G._6061 = _6061;
var _6261 = (...xs) => {
var __xs10 = unstash(xs);
return pairwise((a, b) => {
return a >= b;
}, __xs10);
};
_G._6261 = _6261;
var number = (s) => {
var __n17 = parseFloat(s);
if (! isNaN(__n17)) {
return __n17;
}
};
_G.number = number;
var numberCode63 = (n) => {
return n >= 48 && n <= 57;
};
_G.numberCode63 = numberCode63;
var numeric63 = (s) => {
var __n18 = _35(s);
var __i21 = 0;
while (__i21 < __n18) {
if (! numberCode63(code(s, __i21))) {
return false;
}
__i21 = __i21 + 1;
}
return some63(s);
};
_G.numeric63 = numeric63;
var tostring = (x) => {
return x.toString();
};
_G.tostring = tostring;
var escape = (s) => {
var __s1 = "\"";
var __i22 = 0;
while (__i22 < _35(s)) {
var __c = char(s, __i22);
var __e14;
if (__c === "\n") {
__e14 = "\\n";
} else {
var __e15;
if (__c === "\r") {
__e15 = "\\r";
} else {
var __e16;
if (__c === "\"") {
__e16 = "\\\"";
} else {
var __e17;
if (__c === "\\") {
__e17 = "\\\\";
} else {
__e17 = __c;
}
__e16 = __e17;
}
__e15 = __e16;
}
__e14 = __e15;
}
var __c1 = __e14;
__s1 = __s1 + __c1;
__i22 = __i22 + 1;
}
return __s1 + "\"";
};
_G.escape = escape;
var simpleId63 = (x) => {
var __id3 = string63(x);
var __e18;
if (__id3) {
var ____id = (() => {
try {
return [true, readString(x)];
}
catch (__e91) {
return [false, __e91];
}
})();
var __ok = ____id[0];
var __v10 = ____id[1];
__e18 = __ok && __v10 === x;
} else {
__e18 = __id3;
}
return __e18;
};
_G.simpleId63 = simpleId63;
var str = (x, stack) => {
if (nil63(x)) {
return "nil";
} else {
if (nan63(x)) {
return "nan";
} else {
if (x === inf) {
return "inf";
} else {
if (x === _inf) {
return "-inf";
} else {
if (boolean63(x)) {
if (x) {
return "true";
} else {
return "false";
}
} else {
if (stringLiteral63(x)) {
return x;
} else {
if (simpleId63(x)) {
return x;
} else {
if (string63(x)) {
return escape(x);
} else {
if (atom63(x)) {
return tostring(x);
} else {
if (function63(x)) {
return "function";
} else {
if (stack && in63(x, stack)) {
return "circular";
} else {
var __s = "(";
var __sp = "";
var __xs11 = [];
var __ks = [];
var __l5 = stack || [];
add(__l5, x);
var ____o11 = x;
var __k18 = undefined;
for (__k18 in ____o11) {
var __v11 = ____o11[__k18];
var __e19;
if (numeric63(__k18)) {
__e19 = parseInt(__k18);
} else {
__e19 = __k18;
}
var __k19 = __e19;
if (number63(__k19)) {
__xs11[__k19] = str(__v11, __l5);
} else {
add(__ks, str(__k19, __l5) + ":");
add(__ks, str(__v11, __l5));
}
}
drop(__l5);
var ____o12 = join(__xs11, __ks);
var ____i24 = undefined;
for (____i24 in ____o12) {
var __v12 = ____o12[____i24];
var __e20;
if (numeric63(____i24)) {
__e20 = parseInt(____i24);
} else {
__e20 = ____i24;
}
var ____i241 = __e20;
__s = __s + __sp + __v12;
__sp = " ";
}
return __s + ")";
}
}
}
}
}
}
}
}
}
}
}
};
_G.str = str;
var apply = (f, args) => {
var __args = stash(args);
return f.apply(f, __args);
};
_G.apply = apply;
var call = (f, ...__r81) => {
var ____r81 = unstash(__r81);
var __f = destash33(f, ____r81);
var ____id1 = ____r81;
var __args11 = cut(____id1, 0);
return apply(__f, __args11);
};
_G.call = call;
var setenv = (k, ...__r82) => {
var ____r82 = unstash(__r82);
var __k20 = destash33(k, ____r82);
var ____id2 = ____r82;
var __keys = cut(____id2, 0);
if (string63(__k20)) {
var __e21;
if (__keys.toplevel) {
__e21 = hd(_G.environment);
} else {
__e21 = last(_G.environment);
}
var __frame = __e21;
var __entry = __frame[__k20] || {};
var ____o13 = __keys;
var __k21 = undefined;
for (__k21 in ____o13) {
var __v13 = ____o13[__k21];
var __e22;
if (numeric63(__k21)) {
__e22 = parseInt(__k21);
} else {
__e22 = __k21;
}
var __k22 = __e22;
__entry[__k22] = __v13;
}
__frame[__k20] = __entry;
return __frame[__k20];
}
};
_G.setenv = setenv;
var print = (x) => {
return console.log(x);
};
_G.print = print;
abs = Math.abs;
_G.abs = abs;
acos = Math.acos;
_G.acos = acos;
asin = Math.asin;
_G.asin = asin;
atan = Math.atan;
_G.atan = atan;
atan2 = Math.atan2;
_G.atan2 = atan2;
ceil = Math.ceil;
_G.ceil = ceil;
cos = Math.cos;
_G.cos = cos;
floor = Math.floor;
_G.floor = floor;
log = Math.log;
_G.log = log;
log10 = Math.log10;
_G.log10 = log10;
max = Math.max;
_G.max = max;
min = Math.min;
_G.min = min;
pow = Math.pow;
_G.pow = pow;
random = Math.random;
_G.random = random;
sin = Math.sin;
_G.sin = sin;
sinh = Math.sinh;
_G.sinh = sinh;
sqrt = Math.sqrt;
_G.sqrt = sqrt;
tan = Math.tan;
_G.tan = tan;
tanh = Math.tanh;
_G.tanh = tanh;
trunc = Math.floor;
_G.trunc = trunc;
setenv("quote", {["_stash"]: true, ["macro"]: (form) => {
return quoted(form);
}});
setenv("quasiquote", {["_stash"]: true, ["macro"]: (form) => {
return quasiexpand(form, 1);
}});
setenv("set", {["_stash"]: true, ["macro"]: (...args) => {
var __args2 = unstash(args);
return join(["do"], map((__x10) => {
var ____id4 = __x10;
var __lh = ____id4[0];
var __rh = ____id4[1];
return ["%set", __lh, __rh];
}, pair(__args2)));
}});
setenv("at", {["_stash"]: true, ["macro"]: (l, i) => {
return [l, ["brackets", i]];
}});
setenv("wipe", {["_stash"]: true, ["macro"]: (place) => {
return ["%delete", place];
}});
setenv("list", {["_stash"]: true, ["macro"]: (...body) => {
var __body = unstash(body);
if (keys63(__body)) {
return join(["%object"], mapo((x) => {
return x;
}, __body));
} else {
return join(["%array"], __body);
}
}});
setenv("if", {["_stash"]: true, ["macro"]: (...branches) => {
var __branches = unstash(branches);
return hd(expandIf(__branches));
}});
setenv("case", {["_stash"]: true, ["macro"]: (expr, ...__r90) => {
var ____r90 = unstash(__r90);
var __expr = destash33(expr, ____r90);
var ____id5 = ____r90;
var __clauses = cut(____id5, 0);
var __x11 = unique("x");
var __eq = (_) => {
if (_ === "else") {
return true;
} else {
return ["=", _, __x11];
}
};
var __cl = (__x12) => {
var ____id6 = __x12;
var __a1 = ____id6[0];
var __body1 = cut(____id6, 1);
if (string63(__a1) || number63(__a1) || hd(__a1) === "quote") {
return [__eq(__a1), join(["do"], __body1)];
} else {
if (one63(__a1)) {
return [__eq(hd(__a1)), join(["do"], __body1)];