mirror of
https://github.com/kanaka/mal.git
synced 2024-08-17 17:50:24 +03:00
- Reorder README to have implementation list after "learning tool" bullet. - This also moves tests/ and libs/ into impls. It would be preferrable to have these directories at the top level. However, this causes difficulties with the wasm implementations which need pre-open directories and have trouble with paths starting with "../../". So in lieu of that, symlink those directories to the top-level. - Move the run_argv_test.sh script into the tests directory for general hygiene.
43 lines
1.3 KiB
JSON
43 lines
1.3 KiB
JSON
["do",
|
|
|
|
["def", "env-bind", ["fn", ["env", "b", "e"],
|
|
["if", ["empty?", "b"],
|
|
"env",
|
|
["if", ["=", ["`", "&"],
|
|
["get", ["first", "b"], ["`", "val"]]],
|
|
["assoc!", "env", ["get", ["nth", "b", 1], ["`", "val"]], "e"],
|
|
["env-bind", ["assoc!", "env", ["get", ["first", "b"], ["`", "val"]],
|
|
["first", "e"]],
|
|
["rest", "b"],
|
|
["rest", "e"]]]]]],
|
|
|
|
["def", "env-new", ["fn", ["&", "args"],
|
|
["let", ["env", ["hash-map", ["`", "__outer__"], ["first", "args"]]],
|
|
["if", ["<=", ["count", "args"], 1],
|
|
"env",
|
|
["env-bind", "env", ["get", "args", 1], ["get", "args", 2]]]]]],
|
|
|
|
["def", "env-find", ["fn", ["env", "key"],
|
|
["let", ["k", ["get", "key", ["`", "val"]]],
|
|
["if", ["contains?", "env", "k"],
|
|
"env",
|
|
["if", ["get", "env", ["`", "__outer__"]],
|
|
["env-find", ["get", "env", ["`", "__outer__"]], "key"],
|
|
null]]]]],
|
|
|
|
["def", "env-get", ["fn", ["env", "key"],
|
|
["let", ["k", ["get", "key", ["`", "val"]],
|
|
"e", ["env-find", "env", "key"]],
|
|
["if", "e",
|
|
["get", "e", "k"],
|
|
["throw", ["str", ["`", "'"], "k", ["`", "' not found"]]]]]]],
|
|
|
|
["def", "env-set", ["fn", ["env", "key", "val"],
|
|
["let", ["k", ["get", "key", ["`", "val"]]],
|
|
["do",
|
|
["assoc!", "env", "k", "val"],
|
|
"val"]]]],
|
|
|
|
null
|
|
]
|