3 ["def", "_path", ["require", ["`", "path"]]],
5 ["def", "_node_readline", ["require", [".", "_path", ["`", "resolve"],
7 ["`", "node_readline.js"]]]],
9 ["def", "_string?", ["fn", ["s"],
10 ["and", ["string?", "s"],
11 ["not", ["=", ["`", "\u029e"], ["get", "s", 0]]]]]],
13 ["def", "div", ["fn", ["a", "b"], ["parseInt", ["/", "a", "b"]]]],
15 ["def", "time-ms", ["fn", [],
16 [".", ["new", "Date"], ["`", "getTime"]]]],
19 ["def", "assoc", ["fn", ["src-hm", "&", "kvs"],
20 ["let", ["hm", ["clone", "src-hm"]],
21 ["assocs!", "hm", "kvs"]]]],
23 ["def", "dissoc", ["fn", ["src-hm", "&", "ks"],
24 ["let", ["hm", ["clone", "src-hm"]],
26 ["map", ["fn", ["k"], ["del", "hm", "k"]], "ks"],
29 ["def", "_get", ["fn", ["obj", "key"],
30 ["if", ["null?", "obj"],
32 ["if", ["contains?", "obj", "key"],
33 ["get", "obj", "key"],
36 ["def", "_count", ["fn", ["a"],
37 ["if", ["=", null, "a"],
41 ["def", "_nth", ["fn", ["seq", "idx"],
42 ["if", [">=", "idx", ["count", "seq"]],
43 ["throw", "nth: index out of range"],
44 ["nth", "seq", "idx"]]]],
46 ["def", "_first", ["fn", ["seq"],
47 ["if", ["empty?", "seq"],
51 ["def", "_rest", ["fn", ["seq"],
52 ["if", ["empty?", "seq"],
56 ["def", "_apply", ["fn", ["f", "&", "args"],
57 ["let", ["fn", ["if", ["malfunc?", "f"], ["get", "f", ["`", "fn"]], "f"],
58 "fargs", ["concat", ["slice", "args", 0, ["-", ["count", "args"], 1]],
59 ["nth", "args", ["-", ["count", "args"], 1]]]],
60 ["apply", "fn", "fargs"]]]],
62 ["def", "_map", ["fn", ["f", "seq"],
63 ["let", ["fn", ["if", ["malfunc?", "f"], ["get", "f", ["`", "fn"]], "f"]],
64 ["map", "fn", "seq"]]]],
66 ["def", "_conj", ["fn", ["seq", "&", "a"],
67 ["if", ["list?", "seq"],
68 [".", [".", "a", ["`", "reverse"]], ["`", "concat"], "seq"],
69 ["vectorl", [".", "seq", ["`", "concat"], "a"]]]]],
71 ["def", "_seq", ["fn", ["obj"],
72 ["if", ["list?", "obj"],
73 ["if", [">", ["count", "obj"], 0], "obj", null],
74 ["if", ["vector?", "obj"],
75 ["if", [">", ["count", "obj"], 0], ["slice", "obj", 0], null],
76 ["if", ["string?", "obj"],
77 ["if", [">", ["count", "obj"], 0],
78 [".", "obj", ["`", "split"], ["`", ""]],
80 ["if", ["null?", "obj"],
82 ["throw", "seq: called on non-sequence"]
85 ["def", "with_meta", ["fn", ["obj", "m"],
86 ["let", ["new-obj", ["clone", "obj"]],
88 ["set", "new-obj", ["`", "__meta__"], "m"],
91 ["def", "meta", ["fn", ["obj"],
92 ["if", ["or", ["sequential?", "obj"],
95 ["if", ["contains?", "obj", ["`", "__meta__"]],
96 ["get", "obj", ["`", "__meta__"]],
100 ["def", "reset!", ["fn", ["atm", "val"],
101 ["do", ["set", "atm", ["`", "val"], "val"], "val"]]],
103 ["def", "swap!", ["fn", ["atm", "f", "&", "args"],
104 ["let", ["fn", ["if", ["malfunc?", "f"], ["get", "f", ["`", "fn"]], "f"],
105 "fargs", ["cons", ["get", "atm", ["`", "val"]], "args"],
106 "val", ["apply", "fn", "fargs"]],
108 ["set", "atm", ["`", "val"], "val"],
113 ["`", "="], "equal?",
114 ["`", "throw"], "throw",
116 ["`", "nil?"], "null?",
117 ["`", "true?"], "true?",
118 ["`", "false?"], "false?",
119 ["`", "string?"], "_string?",
120 ["`", "symbol"], "symbol",
121 ["`", "symbol?"], "symbol?",
122 ["`", "keyword"], "keyword",
123 ["`", "keyword?"], "keyword?",
124 ["`", "number?"], "number?",
125 ["`", "fn?"], ["fn", ["a"],
126 ["or", ["function?", "a"],
127 ["and", ["malfunc?", "a"],
128 ["not", ["get", "a", ["`", "macro?"]]]]]],
129 ["`", "macro?"], ["fn", ["a"],
130 ["and", ["malfunc?", "a"],
131 ["get", "a", ["`", "macro?"]]]],
133 ["`", "pr-str"], ["fn", ["&", "a"], ["pr-list", "a", true, ["`", " "]]],
134 ["`", "str"], ["fn", ["&", "a"], ["pr-list", "a", false, ["`", ""]]],
135 ["`", "prn"], ["fn", ["&", "a"],
137 ["println", ["pr-list", "a", true, ["`", " "]]],
139 ["`", "println"], ["fn", ["&", "a"],
141 ["println", ["pr-list", "a", false, ["`", " "]]],
143 ["`", "read-string"], "read-str",
144 ["`", "readline"], ["fn", ["p"],
145 [".", "_node_readline", ["`", "readline"], "p"]],
146 ["`", "slurp"], "slurp",
156 ["`", "time-ms"], "time-ms",
158 ["`", "list"], "list",
159 ["`", "list?"], "list?",
160 ["`", "vector"], "vector",
161 ["`", "vector?"], "vector?",
162 ["`", "hash-map"], "hash-map",
163 ["`", "assoc"], "assoc",
164 ["`", "dissoc"], "dissoc",
165 ["`", "map?"], "map?",
166 ["`", "get"], "_get",
167 ["`", "contains?"], "contains?",
168 ["`", "keys"], "keys",
169 ["`", "vals"], "vals",
171 ["`", "sequential?"], "sequential?",
172 ["`", "cons"], "cons",
173 ["`", "concat"], "concat",
174 ["`", "nth"], "_nth",
175 ["`", "first"], "_first",
176 ["`", "rest"], "_rest",
177 ["`", "empty?"], "empty?",
178 ["`", "count"], "_count",
179 ["`", "apply"], "_apply",
180 ["`", "map"], "_map",
182 ["`", "conj"], "_conj",
183 ["`", "seq"], "_seq",
185 ["`", "with-meta"], "with_meta",
186 ["`", "meta"], "meta",
187 ["`", "atom"], "atom",
188 ["`", "atom?"], "atom?",
189 ["`", "deref"], ["fn", ["a"], ["get", "a", ["`", "val"]]],
190 ["`", "reset!"], "reset!",
191 ["`", "swap!"], "swap!"]],