Commit | Line | Data |
---|---|---|
c1fe72ae JM |
1 | ["do", |
2 | ||
b32495e9 JM |
3 | ["def", "new", ["fn", ["a", "&", "b"], |
4 | [".", "Reflect", ["`", "construct"], "a", "b"]]], | |
5 | ["def", "del", ["fn", ["a", "b"], | |
6 | [".", "Reflect", ["`", "deleteProperty"], "a", "b"]]], | |
7 | ["def", "map", ["fn", ["a", "b"], | |
8 | [".", "b", ["`", "map"], ["fn", ["x"], ["a", "x"]]]]], | |
9 | ["def", "list", ["fn", ["&", "a"], "a"]], | |
10 | ["def", ">=", ["fn", ["a", "b"], | |
11 | ["if", ["<", "a", "b"], false, true]]], | |
12 | ["def", ">", ["fn", ["a", "b"], | |
13 | ["if", [">=", "a", "b"], | |
14 | ["if", ["=", "a", "b"], false, true], | |
15 | false]]], | |
16 | ["def", "<=", ["fn", ["a", "b"], | |
17 | ["if", [">", "a", "b"], false, true]]], | |
18 | ||
19 | ["def", "classOf", ["fn", ["a"], | |
20 | [".", [".-", [".-", "Object", ["`", "prototype"]], ["`", "toString"]], | |
21 | ["`", "call"], "a"]]], | |
22 | ||
c1fe72ae JM |
23 | ["def", "not", ["fn", ["a"], ["if", "a", false, true]]], |
24 | ||
b32495e9 | 25 | ["def", "null?", ["fn", ["a"], ["=", null, "a"]]], |
c1fe72ae JM |
26 | ["def", "true?", ["fn", ["a"], ["=", true, "a"]]], |
27 | ["def", "false?", ["fn", ["a"], ["=", false, "a"]]], | |
28 | ["def", "string?", ["fn", ["a"], | |
29 | ["if", ["=", "a", null], | |
30 | false, | |
31 | ["=", ["`", "String"], | |
32 | [".-", [".-", "a", ["`", "constructor"]], | |
33 | ["`", "name"]]]]]], | |
b156d1f1 JM |
34 | ["def", "number?", ["fn", ["a"], |
35 | ["=", ["`", "[object Number]"], ["classOf", "a"]]]], | |
36 | ["def", "function?", ["fn", ["a"], | |
37 | ["isa", "a", "Function"]]], | |
c1fe72ae | 38 | |
b32495e9 | 39 | ["def", "pr-list*", ["fn", ["a", "b", "c"], |
c1fe72ae | 40 | [".", ["map", ["fn", ["x"], |
b32495e9 | 41 | ["if", "c", |
c1fe72ae JM |
42 | [".", "JSON", ["`", "stringify"], "x"], |
43 | ["if", ["string?", "x"], | |
44 | "x", | |
45 | [".", "JSON", ["`", "stringify"], "x"]]]], | |
46 | "a"], | |
b32495e9 | 47 | ["`", "join"], "b"]]], |
c1fe72ae | 48 | ["def", "pr-str", ["fn", ["&", "a"], |
b32495e9 | 49 | ["pr-list*", "a", ["`", " "], true]]], |
c1fe72ae | 50 | ["def", "str", ["fn", ["&", "a"], |
b32495e9 | 51 | ["pr-list*", "a", ["`", ""], false]]], |
c1fe72ae | 52 | ["def", "prn", ["fn", ["&", "a"], |
b32495e9 JM |
53 | ["do", [".", "console", ["`", "log"], |
54 | ["pr-list*", "a", ["`", " "], true]], null]]], | |
c1fe72ae | 55 | ["def", "println", ["fn", ["&", "a"], |
b32495e9 JM |
56 | ["do", [".", "console", ["`", "log"], |
57 | ["pr-list*", "a", ["`", " "], false]], null]]], | |
c1fe72ae | 58 | |
b32495e9 JM |
59 | ["def", "list?", ["fn", ["a"], |
60 | [".", "Array", ["`", "isArray"], "a"]]], | |
61 | ["def", "contains?", ["fn", ["a", "b"], | |
62 | [".", "a", ["`", "hasOwnProperty"], "b"]]], | |
63 | ["def", "get", ["fn", ["a", "b"], | |
64 | ["if", ["contains?", "a", "b"], [".-", "a", "b"], null]]], | |
65 | ["def", "set", ["fn", ["a", "b", "c"], | |
66 | ["do", [".-", "a", "b", "c"], "a"]]], | |
67 | ["def", "keys", ["fn", ["a"], | |
68 | [".", "Object", ["`", "keys"], "a"]]], | |
69 | ["def", "vals", ["fn", ["a"], | |
70 | ["map",["fn", ["k"], ["get", "a", "k"]], ["keys", "a"]]]], | |
c1fe72ae JM |
71 | |
72 | ["def", "cons", ["fn", ["a", "b"], | |
73 | [".", ["`", []], | |
74 | ["`", "concat"], ["list", "a"], "b"]]], | |
75 | ["def", "concat", ["fn", ["&", "a"], | |
76 | [".", [".-", ["list"], ["`", "concat"]], | |
77 | ["`", "apply"], ["list"], "a"]]], | |
78 | ["def", "nth", "get"], | |
b32495e9 JM |
79 | ["def", "first", ["fn", ["a"], |
80 | ["if", [">", [".-", "a", ["`", "length"]], 0], | |
81 | ["nth", "a", 0], | |
82 | null]]], | |
83 | ["def", "last", ["fn", ["a"], | |
84 | ["nth", "a", ["-", [".-", "a", ["`", "length"]], 1]]]], | |
c1fe72ae JM |
85 | ["def", "count", ["fn", ["a"], |
86 | [".-", "a", ["`", "length"]]]], | |
b32495e9 JM |
87 | ["def", "empty?", ["fn", ["a"], |
88 | ["if", ["list?", "a"], | |
89 | ["if", ["=", 0, [".-", "a", ["`", "length"]]], true, false], | |
90 | ["=", "a", null]]]], | |
91 | ["def", "slice", ["fn", ["a", "b", "&", "end"], | |
92 | [".", "a", ["`", "slice"], "b", | |
93 | ["if", [">", ["count", "end"], 0], | |
94 | ["get", "end", 0], | |
95 | [".-", "a", ["`", "length"]]]]]], | |
96 | ["def", "rest", ["fn", ["a"], ["slice", "a", 1]]], | |
c1fe72ae | 97 | |
b32495e9 JM |
98 | ["def", "apply", ["fn", ["f", "&", "b"], |
99 | [".", "f", ["`", "apply"], "f", | |
100 | ["concat", ["slice", "b", 0, -1], ["last", "b"]]]]], | |
c1fe72ae | 101 | |
1981bf57 JM |
102 | ["def", "and", ["~", ["fn", ["&", "xs"], |
103 | ["if", ["empty?", "xs"], | |
104 | true, | |
105 | ["if", ["=", 1, ["count", "xs"]], | |
106 | ["first", "xs"], | |
107 | ["list", ["`", "let"], ["list", ["`", "and_FIXME"], ["first", "xs"]], | |
108 | ["list", ["`", "if"], ["`", "and_FIXME"], | |
109 | ["concat", ["`", ["and"]], ["rest", "xs"]], | |
110 | ["`", "and_FIXME"]]]]]]]], | |
111 | ||
7ebf5219 | 112 | ["def", "or", ["~", ["fn", ["&", "xs"], |
1981bf57 JM |
113 | ["if", ["empty?", "xs"], |
114 | null, | |
115 | ["if", ["=", 1, ["count", "xs"]], | |
116 | ["first", "xs"], | |
117 | ["list", ["`", "let"], ["list", ["`", "or_FIXME"], ["first", "xs"]], | |
118 | ["list", ["`", "if"], ["`", "or_FIXME"], | |
119 | ["`", "or_FIXME"], | |
120 | ["concat", ["`", ["or"]], ["rest", "xs"]]]]]]]]], | |
7ebf5219 | 121 | |
c1fe72ae | 122 | ["def", "repl", ["fn",["prompt", "rep"], |
c727d1c8 | 123 | ["let", ["readline", ["require", ["`", "readline"]], |
b32495e9 | 124 | "opts", ["new", "Object"], |
c727d1c8 JM |
125 | "_", ["set", "opts", ["`", "input"], [".-", "process", ["`", "stdin"]]], |
126 | "_", ["set", "opts", ["`", "output"], [".-", "process", ["`", "stdout"]]], | |
127 | "_", ["set", "opts", ["`", "terminal"], false], | |
128 | "rl", [".", "readline", ["`", "createInterface"], "opts"], | |
129 | "evl", ["fn", ["line"], | |
130 | ["do", | |
131 | ["println", ["rep", "line"]], | |
132 | [".", "rl", ["`", "prompt"]]]]], | |
10b07148 | 133 | ["do", |
c727d1c8 JM |
134 | [".", "rl", ["`", "setPrompt"], "prompt"], |
135 | [".", "rl", ["`", "prompt"]], | |
136 | [".", "rl", ["`", "on"], ["`", "line"], "evl"]]]]], | |
c1fe72ae JM |
137 | |
138 | null | |
c1fe72ae JM |
139 | ] |
140 |