Travis: comment out self-host tests in master.
[jackhill/mal.git] / miniMAL / core.json
CommitLineData
c5d30235
JM
1["do",
2
2774a151
JM
3["def", "_path", ["require", ["`", "path"]]],
4
5["def", "_node_readline", ["require", [".", "_path", ["`", "resolve"],
6 ["`", "."],
7 ["`", "node_readline.js"]]]],
8
c5d30235
JM
9["def", "div", ["fn", ["a", "b"], ["parseInt", ["/", "a", "b"]]]],
10
d90c7844
JM
11["def", "time-ms", ["fn", [],
12 [".", ["new", "Date"], ["`", "getTime"]]]],
13
32045546
JM
14
15["def", "assoc", ["fn", ["src-hm", "&", "kvs"],
16 ["let", ["hm", ["clone", "src-hm"]],
17 ["assocs!", "hm", "kvs"]]]],
18
19["def", "dissoc", ["fn", ["src-hm", "&", "ks"],
20 ["let", ["hm", ["clone", "src-hm"]],
21 ["do",
22 ["map", ["fn", ["k"], ["del", "hm", "k"]], "ks"],
23 "hm"]]]],
24
25["def", "_get", ["fn", ["obj", "key"],
26 ["if", ["nil?", "obj"],
27 null,
28 ["if", ["contains?", "obj", "key"],
29 ["get", "obj", "key"],
30 null]]]],
31
c5d30235
JM
32["def", "_count", ["fn", ["a"],
33 ["if", ["=", null, "a"],
34 0,
35 ["count", "a"]]]],
36
f618f6a1
JM
37["def", "_nth", ["fn", ["seq", "idx"],
38 ["if", [">=", "idx", ["count", "seq"]],
39 ["throw", "nth: index out of range"],
40 ["nth", "seq", "idx"]]]],
41
42["def", "_first", ["fn", ["seq"],
43 ["if", ["empty?", "seq"],
44 null,
45 ["first", "seq"]]]],
46
2774a151
JM
47["def", "_apply", ["fn", ["f", "&", "args"],
48 ["let", ["fn", ["if", ["malfunc?", "f"], ["get", "f", ["`", "fn"]], "f"],
49 "fargs", ["concat", ["slice", "args", 0, ["-", ["count", "args"], 1]],
50 ["nth", "args", ["-", ["count", "args"], 1]]]],
51 ["apply", "fn", "fargs"]]]],
52
53["def", "_map", ["fn", ["f", "seq"],
54 ["let", ["fn", ["if", ["malfunc?", "f"], ["get", "f", ["`", "fn"]], "f"]],
55 ["map", "fn", "seq"]]]],
56
ad28cf3c
JM
57["def", "with_meta", ["fn", ["obj", "m"],
58 ["let", ["new-obj", ["clone", "obj"]],
59 ["do",
60 ["set", "new-obj", ["`", "__meta__"], "m"],
61 "new-obj"]]]],
62
63["def", "meta", ["fn", ["obj"],
64 ["if", ["or", ["sequential?", "obj"],
65 ["map?", "obj"],
66 ["malfunc?", "obj"]],
67 ["if", ["contains?", "obj", ["`", "__meta__"]],
68 ["get", "obj", ["`", "__meta__"]],
69 null],
70 null]]],
71
8cfab776
JM
72["def", "reset!", ["fn", ["atm", "val"],
73 ["set", "atm", ["`", "val"], "val"]]],
74
75["def", "swap!", ["fn", ["atm", "f", "&", "args"],
76 ["let", ["fn", ["if", ["malfunc?", "f"], ["get", "f", ["`", "fn"]], "f"],
77 "fargs", ["cons", ["get", "atm", ["`", "val"]], "args"],
78 "val", ["apply", "fn", "fargs"]],
79 ["do",
80 ["set", "atm", ["`", "val"], "val"],
81 "val"]]]],
ad28cf3c 82
c5d30235
JM
83["def", "core-ns",
84 ["hash-map",
2774a151
JM
85 ["`", "="], "equal?",
86 ["`", "throw"], "throw",
87
88 ["`", "nil?"], "nil?",
89 ["`", "true?"], "true?",
90 ["`", "false?"], "false?",
91 ["`", "symbol"], "symbol",
92 ["`", "symbol?"], "symbol?",
32045546
JM
93 ["`", "keyword"], "keyword",
94 ["`", "keyword?"], "keyword?",
c5d30235
JM
95
96 ["`", "pr-str"], ["fn", ["&", "a"], ["pr-list", "a", true, ["`", " "]]],
97 ["`", "str"], ["fn", ["&", "a"], ["pr-list", "a", false, ["`", ""]]],
98 ["`", "prn"], ["fn", ["&", "a"],
99 ["do",
100 ["println", ["pr-list", "a", true, ["`", " "]]],
101 null]],
102 ["`", "println"], ["fn", ["&", "a"],
103 ["do",
104 ["println", ["pr-list", "a", false, ["`", " "]]],
105 null]],
9d8f0299 106 ["`", "read-string"], "read-str",
2774a151
JM
107 ["`", "readline"], ["fn", ["p"],
108 [".", "_node_readline", ["`", "readline"], "p"]],
9d8f0299 109 ["`", "slurp"], "slurp",
c5d30235
JM
110
111 ["`", "<"], "<",
112 ["`", "<="], "<=",
113 ["`", ">"], ">",
114 ["`", ">="], ">=",
115 ["`", "+"], "+",
116 ["`", "-"], "-",
117 ["`", "*"], "*",
118 ["`", "/"], "div",
d90c7844 119 ["`", "time-ms"], "time-ms",
c5d30235 120
32045546
JM
121 ["`", "list"], "list",
122 ["`", "list?"], "list?",
123 ["`", "vector"], "vector",
124 ["`", "vector?"], "vector?",
125 ["`", "hash-map"], "hash-map",
126 ["`", "assoc"], "assoc",
127 ["`", "dissoc"], "dissoc",
128 ["`", "map?"], "map?",
129 ["`", "get"], "_get",
130 ["`", "contains?"], "contains?",
131 ["`", "keys"], "keys",
132 ["`", "vals"], "vals",
133
134 ["`", "sequential?"], "sequential?",
1981bf57
JM
135 ["`", "cons"], "cons",
136 ["`", "concat"], "concat",
f618f6a1
JM
137 ["`", "nth"], "_nth",
138 ["`", "first"], "_first",
139 ["`", "rest"], ["fn", ["a"], ["rest", "a"]],
c5d30235 140 ["`", "empty?"], "empty?",
8cfab776
JM
141 ["`", "count"], "_count",
142 ["`", "apply"], "_apply",
143 ["`", "map"], "_map",
144 ["`", "conj"], null,
ad28cf3c
JM
145
146 ["`", "with-meta"], "with_meta",
8cfab776
JM
147 ["`", "meta"], "meta",
148 ["`", "atom"], "atom",
149 ["`", "atom?"], "atom?",
150 ["`", "deref"], ["fn", ["a"], ["get", "a", ["`", "val"]]],
151 ["`", "reset!"], "reset!",
152 ["`", "swap!"], "swap!"]],
c5d30235
JM
153
154null]