1
1
mirror of https://github.com/kanaka/mal.git synced 2024-08-17 17:50:24 +03:00
mal/impls/miniMAL/core.json
Joel Martin 6bf89ea118 miniMAL: update to miniMAL-1.2.2
- Update to ubuntu 24.04 Dockerfile and add labels.
- update to working version of ffi-napi
- Remove from miniMAL-core.json the things that overlap with the builtin
  core functionality that miniMAL now provides in 1.2.2.
- Update ARGS variable to argv to align with how 1.2.2 now does command
  line parameters.
2024-08-03 11:06:43 -05:00

201 lines
5.9 KiB
JSON

["do",
["def", "_path", ["require", ["`", "path"]]],
["def", "_node_readline", ["require", [".", "_path", ["`", "resolve"],
["`", "."],
["`", "node_readline.js"]]]],
["def", "_string?", ["fn", ["s"],
["and", ["string?", "s"],
["not", ["=", ["`", "\u029e"], ["get", "s", 0]]]]]],
["def", "_function?", ["fn", ["a"],
["isa", "a", "Function"]]],
["def", "_number?", ["fn", ["a"],
["=", ["`", "[object Number]"], ["classOf", "a"]]]],
["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", ["null?", "obj"],
null,
["if", ["contains?", "obj", "key"],
["get", "obj", "key"],
null]]]],
["def", "_count", ["fn", ["a"],
["if", ["=", null, "a"],
0,
["count", "a"]]]],
["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"]]]],
["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"]]]],
["def", "_conj", ["fn", ["seq", "&", "a"],
["if", ["list?", "seq"],
[".", [".", "a", ["`", "reverse"]], ["`", "concat"], "seq"],
["vectorl", [".", "seq", ["`", "concat"], "a"]]]]],
["def", "_seq", ["fn", ["obj"],
["if", ["list?", "obj"],
["if", [">", ["count", "obj"], 0], "obj", null],
["if", ["vector?", "obj"],
["if", [">", ["count", "obj"], 0], ["slice", "obj", 0], null],
["if", ["string?", "obj"],
["if", [">", ["count", "obj"], 0],
[".", "obj", ["`", "split"], ["`", ""]],
null],
["if", ["null?", "obj"],
null,
["throw", "seq: called on non-sequence"]
]]]]]],
["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"],
["do", ["set", "atm", ["`", "val"], "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"]]]],
["def", "core-ns",
["hash-map",
["`", "="], "equal?",
["`", "throw"], "throw",
["`", "nil?"], "null?",
["`", "true?"], "true?",
["`", "false?"], "false?",
["`", "string?"], "_string?",
["`", "symbol"], "symbol",
["`", "symbol?"], "symbol?",
["`", "keyword"], "keyword",
["`", "keyword?"], "keyword?",
["`", "number?"], "_number?",
["`", "fn?"], ["fn", ["a"],
["or", ["_function?", "a"],
["and", ["malfunc?", "a"],
["not", ["get", "a", ["`", "macro?"]]]]]],
["`", "macro?"], ["fn", ["a"],
["and", ["malfunc?", "a"],
["get", "a", ["`", "macro?"]]]],
["`", "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]],
["`", "read-string"], "read-str",
["`", "readline"], ["fn", ["p"],
[".", "_node_readline", ["`", "readline"], "p"]],
["`", "slurp"], "slurp",
["`", "<"], "<",
["`", "<="], "<=",
["`", ">"], ">",
["`", ">="], ">=",
["`", "+"], "+",
["`", "-"], "-",
["`", "*"], "*",
["`", "/"], "div",
["`", "time-ms"], "time-ms",
["`", "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?",
["`", "cons"], "cons",
["`", "concat"], "concat",
["`", "vec"], "vectorl",
["`", "nth"], "_nth",
["`", "first"], "_first",
["`", "rest"], "_rest",
["`", "empty?"], "empty?",
["`", "count"], "_count",
["`", "apply"], "_apply",
["`", "map"], "_map",
["`", "conj"], "_conj",
["`", "seq"], "_seq",
["`", "with-meta"], "with_meta",
["`", "meta"], "meta",
["`", "atom"], "atom",
["`", "atom?"], "atom?",
["`", "deref"], ["fn", ["a"], ["get", "a", ["`", "val"]]],
["`", "reset!"], "reset!",
["`", "swap!"], "swap!"]],
null]