Commit | Line | Data |
---|---|---|
c1fe72ae JM |
1 | ["do", |
2 | ||
3 | ["def", "map", ["fn", ["a", "b"], [".", "b", ["`", "map"], "a"]]], | |
4 | ["def", "not", ["fn", ["a"], ["if", "a", false, true]]], | |
5 | ||
6 | ["def", "nil?", ["fn", ["a"], ["=", null, "a"]]], | |
7 | ["def", "true?", ["fn", ["a"], ["=", true, "a"]]], | |
8 | ["def", "false?", ["fn", ["a"], ["=", false, "a"]]], | |
9 | ["def", "string?", ["fn", ["a"], | |
10 | ["if", ["=", "a", null], | |
11 | false, | |
12 | ["=", ["`", "String"], | |
13 | [".-", [".-", "a", ["`", "constructor"]], | |
14 | ["`", "name"]]]]]], | |
15 | ||
16 | ["def", "pr-list*", ["fn", ["a", "pr", "sep"], | |
17 | [".", ["map", ["fn", ["x"], | |
18 | ["if", "pr", | |
19 | [".", "JSON", ["`", "stringify"], "x"], | |
20 | ["if", ["string?", "x"], | |
21 | "x", | |
22 | [".", "JSON", ["`", "stringify"], "x"]]]], | |
23 | "a"], | |
24 | ["`", "join"], "sep"]]], | |
25 | ["def", "pr-str", ["fn", ["&", "a"], | |
26 | ["pr-list*", "a", true, ["`", " "]]]], | |
27 | ["def", "str", ["fn", ["&", "a"], | |
28 | ["pr-list*", "a", false, ["`", ""]]]], | |
29 | ["def", "prn", ["fn", ["&", "a"], | |
30 | [".", "console", ["`", "log"], | |
31 | ["pr-list*", "a", true, ["`", " "]]]]], | |
32 | ["def", "println", ["fn", ["&", "a"], | |
33 | [".", "console", ["`", "log"], | |
34 | ["pr-list*", "a", false, ["`", " "]]]]], | |
35 | ||
36 | ["def", ">=", ["fn", ["a", "b"], | |
37 | ["if", ["<", "a", "b"], false, true]]], | |
38 | ["def", ">", ["fn", ["a", "b"], | |
39 | ["if", [">=", "a", "b"], ["if", ["=", "a", "b"], false, true], false]]], | |
40 | ["def", "<=", ["fn", ["a", "b"], | |
41 | ["if", [">", "a", "b"], false, true]]], | |
42 | ||
43 | ["def", "list", ["fn", ["&", "a"], "a"]], | |
44 | ["def", "list?", ["fn", ["a"], [".", "Array", ["`", "isArray"], "a"]]], | |
c1fe72ae JM |
45 | ["def", "get", ["fn", ["a", "b"], [".-", "a", "b"]]], |
46 | ["def", "set", ["fn", ["a", "b", "c"], [".-", "a", "b", "c"]]], | |
47 | ["def", "contains?", ["fn", ["a", "b"], [".", "a", ["`", "hasOwnProperty"], "b"]]], | |
48 | ["def", "keys", ["fn", ["a"], [".", "Object", ["`", "keys"], "a"]]], | |
49 | ["def", "vals", ["fn", ["a"], ["map",["fn",["k"],["get","a","k"]],["keys", "a"]]]], | |
50 | ||
51 | ["def", "cons", ["fn", ["a", "b"], | |
52 | [".", ["`", []], | |
53 | ["`", "concat"], ["list", "a"], "b"]]], | |
54 | ["def", "concat", ["fn", ["&", "a"], | |
55 | [".", [".-", ["list"], ["`", "concat"]], | |
56 | ["`", "apply"], ["list"], "a"]]], | |
57 | ["def", "nth", "get"], | |
58 | ["def", "first", ["fn", ["a"], ["nth", "a", 0]]], | |
59 | ["def", "rest", ["fn", ["a"], [".", "a", ["`", "slice"], 1]]], | |
60 | ["def", "empty?", ["fn", ["a"], ["if", ["list?", "a"], ["if", ["=", 0, [".-", "a", ["`", "length"]]], true, false], ["=", "a", null]]]], | |
61 | ["def", "count", ["fn", ["a"], | |
62 | [".-", "a", ["`", "length"]]]], | |
63 | ["def", "slice", ["fn", ["a", "start", "&", "endl"], | |
64 | ["let", ["end", ["if", ["count", "endl"], | |
65 | ["get", "endl", 0], | |
66 | [".-", "a", ["`", "length"]]]], | |
67 | [".", "a", ["`", "slice"], "start", "end"]]]], | |
68 | ||
69 | ["def", "apply", ["fn", ["a", "b"], [".", "a", ["`", "apply"], "a", "b"]]], | |
70 | ||
1981bf57 JM |
71 | ["def", "and", ["~", ["fn", ["&", "xs"], |
72 | ["if", ["empty?", "xs"], | |
73 | true, | |
74 | ["if", ["=", 1, ["count", "xs"]], | |
75 | ["first", "xs"], | |
76 | ["list", ["`", "let"], ["list", ["`", "and_FIXME"], ["first", "xs"]], | |
77 | ["list", ["`", "if"], ["`", "and_FIXME"], | |
78 | ["concat", ["`", ["and"]], ["rest", "xs"]], | |
79 | ["`", "and_FIXME"]]]]]]]], | |
80 | ||
7ebf5219 | 81 | ["def", "or", ["~", ["fn", ["&", "xs"], |
1981bf57 JM |
82 | ["if", ["empty?", "xs"], |
83 | null, | |
84 | ["if", ["=", 1, ["count", "xs"]], | |
85 | ["first", "xs"], | |
86 | ["list", ["`", "let"], ["list", ["`", "or_FIXME"], ["first", "xs"]], | |
87 | ["list", ["`", "if"], ["`", "or_FIXME"], | |
88 | ["`", "or_FIXME"], | |
89 | ["concat", ["`", ["or"]], ["rest", "xs"]]]]]]]]], | |
7ebf5219 | 90 | |
3fb3743f JM |
91 | ["def", "classOf", ["fn", ["a"], |
92 | [".", [".-", [".-", "Object", ["`", "prototype"]], ["`", "toString"]], | |
93 | ["`", "call"], "a"]]], | |
32045546 | 94 | |
c1fe72ae JM |
95 | |
96 | ["def", "repl", ["fn",["prompt", "rep"], | |
97 | ["let", ["r", ["require", ["`", "repl"]], | |
98 | "evl", ["fn", ["l", "c", "f", "cb"], | |
99 | ["let", ["line", ["slice", "l", 1, ["-", [".-", "l", ["`", "length"]], 2]]], | |
100 | ["do", | |
101 | ["println", ["rep", "line"]], | |
102 | ["cb"]]]], | |
103 | "opts", {"ignoreUndefined": true, | |
10b07148 JM |
104 | "terminal": false}], |
105 | ["do", | |
106 | [".-", "opts", ["`", "prompt"], "prompt"], | |
107 | [".-", "opts", ["`", "eval"], "evl"], | |
108 | [".", "r", ["`", "start"], "opts"]]]]], | |
c1fe72ae JM |
109 | |
110 | null | |
c1fe72ae JM |
111 | ] |
112 |