| 1 | ["do", |
| 2 | |
| 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 | |
| 23 | ["def", "not", ["fn", ["a"], ["if", "a", false, true]]], |
| 24 | |
| 25 | ["def", "null?", ["fn", ["a"], ["=", null, "a"]]], |
| 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"]]]]]], |
| 34 | ["def", "number?", ["fn", ["a"], |
| 35 | ["=", ["`", "[object Number]"], ["classOf", "a"]]]], |
| 36 | ["def", "function?", ["fn", ["a"], |
| 37 | ["isa", "a", "Function"]]], |
| 38 | |
| 39 | ["def", "pr-list*", ["fn", ["a", "b", "c"], |
| 40 | [".", ["map", ["fn", ["x"], |
| 41 | ["if", "c", |
| 42 | [".", "JSON", ["`", "stringify"], "x"], |
| 43 | ["if", ["string?", "x"], |
| 44 | "x", |
| 45 | [".", "JSON", ["`", "stringify"], "x"]]]], |
| 46 | "a"], |
| 47 | ["`", "join"], "b"]]], |
| 48 | ["def", "pr-str", ["fn", ["&", "a"], |
| 49 | ["pr-list*", "a", ["`", " "], true]]], |
| 50 | ["def", "str", ["fn", ["&", "a"], |
| 51 | ["pr-list*", "a", ["`", ""], false]]], |
| 52 | ["def", "prn", ["fn", ["&", "a"], |
| 53 | ["do", [".", "console", ["`", "log"], |
| 54 | ["pr-list*", "a", ["`", " "], true]], null]]], |
| 55 | ["def", "println", ["fn", ["&", "a"], |
| 56 | ["do", [".", "console", ["`", "log"], |
| 57 | ["pr-list*", "a", ["`", " "], false]], null]]], |
| 58 | |
| 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"]]]], |
| 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"], |
| 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]]]], |
| 85 | ["def", "count", ["fn", ["a"], |
| 86 | [".-", "a", ["`", "length"]]]], |
| 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]]], |
| 97 | |
| 98 | ["def", "apply", ["fn", ["f", "&", "b"], |
| 99 | [".", "f", ["`", "apply"], "f", |
| 100 | ["concat", ["slice", "b", 0, -1], ["last", "b"]]]]], |
| 101 | |
| 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 | |
| 112 | ["def", "or", ["~", ["fn", ["&", "xs"], |
| 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"]]]]]]]]], |
| 121 | |
| 122 | ["def", "repl", ["fn",["prompt", "rep"], |
| 123 | ["let", ["readline", ["require", ["`", "readline"]], |
| 124 | "opts", ["new", "Object"], |
| 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"]]]]], |
| 133 | ["do", |
| 134 | [".", "rl", ["`", "setPrompt"], "prompt"], |
| 135 | [".", "rl", ["`", "prompt"]], |
| 136 | [".", "rl", ["`", "on"], ["`", "line"], "evl"]]]]], |
| 137 | |
| 138 | null |
| 139 | ] |
| 140 | |