1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-17 16:47:22 +03:00
mal/miniMAL/core.json

160 lines
4.6 KiB
JSON
Raw Normal View History

2015-02-16 01:34:55 +03:00
["do",
2015-02-16 08:33:08 +03:00
["def", "_path", ["require", ["`", "path"]]],
["def", "_node_readline", ["require", [".", "_path", ["`", "resolve"],
["`", "."],
["`", "node_readline.js"]]]],
2015-02-16 01:34:55 +03:00
["def", "div", ["fn", ["a", "b"], ["parseInt", ["/", "a", "b"]]]],
["def", "time-ms", ["fn", [],
[".", ["new", "Date"], ["`", "getTime"]]]],
["def", "assoc", ["fn", ["src-hm", "&", "kvs"],
["let", ["hm", ["clone", "src-hm"]],
["assocs!", "hm", "kvs"]]]],
["def", "dissoc", ["fn", ["src-hm", "&", "ks"],
["let", ["hm", ["clone", "src-hm"]],
["do",
["map", ["fn", ["k"], ["del", "hm", "k"]], "ks"],
"hm"]]]],
["def", "_get", ["fn", ["obj", "key"],
["if", ["nil?", "obj"],
null,
["if", ["contains?", "obj", "key"],
["get", "obj", "key"],
null]]]],
2015-02-16 01:34:55 +03:00
["def", "_count", ["fn", ["a"],
["if", ["=", null, "a"],
0,
["count", "a"]]]],
2015-02-16 07:04:45 +03:00
["def", "_nth", ["fn", ["seq", "idx"],
["if", [">=", "idx", ["count", "seq"]],
["throw", "nth: index out of range"],
["nth", "seq", "idx"]]]],
["def", "_first", ["fn", ["seq"],
["if", ["empty?", "seq"],
null,
["first", "seq"]]]],
["def", "_rest", ["fn", ["seq"],
["if", ["empty?", "seq"],
["`", []],
["rest", "seq"]]]],
2015-02-16 08:33:08 +03:00
["def", "_apply", ["fn", ["f", "&", "args"],
["let", ["fn", ["if", ["malfunc?", "f"], ["get", "f", ["`", "fn"]], "f"],
"fargs", ["concat", ["slice", "args", 0, ["-", ["count", "args"], 1]],
["nth", "args", ["-", ["count", "args"], 1]]]],
["apply", "fn", "fargs"]]]],
["def", "_map", ["fn", ["f", "seq"],
["let", ["fn", ["if", ["malfunc?", "f"], ["get", "f", ["`", "fn"]], "f"]],
["map", "fn", "seq"]]]],
2015-02-16 10:15:35 +03:00
["def", "with_meta", ["fn", ["obj", "m"],
["let", ["new-obj", ["clone", "obj"]],
["do",
["set", "new-obj", ["`", "__meta__"], "m"],
"new-obj"]]]],
["def", "meta", ["fn", ["obj"],
["if", ["or", ["sequential?", "obj"],
["map?", "obj"],
["malfunc?", "obj"]],
["if", ["contains?", "obj", ["`", "__meta__"]],
["get", "obj", ["`", "__meta__"]],
null],
null]]],
["def", "reset!", ["fn", ["atm", "val"],
["set", "atm", ["`", "val"], "val"]]],
["def", "swap!", ["fn", ["atm", "f", "&", "args"],
["let", ["fn", ["if", ["malfunc?", "f"], ["get", "f", ["`", "fn"]], "f"],
"fargs", ["cons", ["get", "atm", ["`", "val"]], "args"],
"val", ["apply", "fn", "fargs"]],
["do",
["set", "atm", ["`", "val"], "val"],
"val"]]]],
2015-02-16 10:15:35 +03:00
2015-02-16 01:34:55 +03:00
["def", "core-ns",
["hash-map",
2015-02-16 08:33:08 +03:00
["`", "="], "equal?",
["`", "throw"], "throw",
["`", "nil?"], "nil?",
["`", "true?"], "true?",
["`", "false?"], "false?",
["`", "symbol"], "symbol",
["`", "symbol?"], "symbol?",
["`", "keyword"], "keyword",
["`", "keyword?"], "keyword?",
2015-02-16 01:34:55 +03:00
["`", "pr-str"], ["fn", ["&", "a"], ["pr-list", "a", true, ["`", " "]]],
["`", "str"], ["fn", ["&", "a"], ["pr-list", "a", false, ["`", ""]]],
["`", "prn"], ["fn", ["&", "a"],
["do",
["println", ["pr-list", "a", true, ["`", " "]]],
null]],
["`", "println"], ["fn", ["&", "a"],
["do",
["println", ["pr-list", "a", false, ["`", " "]]],
null]],
2015-02-16 05:11:11 +03:00
["`", "read-string"], "read-str",
2015-02-16 08:33:08 +03:00
["`", "readline"], ["fn", ["p"],
[".", "_node_readline", ["`", "readline"], "p"]],
2015-02-16 05:11:11 +03:00
["`", "slurp"], "slurp",
2015-02-16 01:34:55 +03:00
["`", "<"], "<",
["`", "<="], "<=",
["`", ">"], ">",
["`", ">="], ">=",
["`", "+"], "+",
["`", "-"], "-",
["`", "*"], "*",
["`", "/"], "div",
["`", "time-ms"], "time-ms",
2015-02-16 01:34:55 +03:00
["`", "list"], "list",
["`", "list?"], "list?",
["`", "vector"], "vector",
["`", "vector?"], "vector?",
["`", "hash-map"], "hash-map",
["`", "assoc"], "assoc",
["`", "dissoc"], "dissoc",
["`", "map?"], "map?",
["`", "get"], "_get",
["`", "contains?"], "contains?",
["`", "keys"], "keys",
["`", "vals"], "vals",
["`", "sequential?"], "sequential?",
2015-02-16 05:46:19 +03:00
["`", "cons"], "cons",
["`", "concat"], "concat",
2015-02-16 07:04:45 +03:00
["`", "nth"], "_nth",
["`", "first"], "_first",
["`", "rest"], "_rest",
2015-02-16 01:34:55 +03:00
["`", "empty?"], "empty?",
["`", "count"], "_count",
["`", "apply"], "_apply",
["`", "map"], "_map",
["`", "conj"], null,
2015-02-16 10:15:35 +03:00
["`", "with-meta"], "with_meta",
["`", "meta"], "meta",
["`", "atom"], "atom",
["`", "atom?"], "atom?",
["`", "deref"], ["fn", ["a"], ["get", "a", ["`", "val"]]],
["`", "reset!"], "reset!",
["`", "swap!"], "swap!"]],
2015-02-16 01:34:55 +03:00
null]