mirror of
https://github.com/kanaka/mal.git
synced 2024-09-11 21:57:38 +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.
29 lines
1.3 KiB
Plaintext
29 lines
1.3 KiB
Plaintext
# {key: string, value: {kkind: kind, value: value}} -> [{kind: value.kkind, value: key}, value.value]
|
|
def _reconstruct_hash:
|
|
map([{
|
|
kind: .value.kkind,
|
|
value: .key
|
|
},
|
|
.value.value]);
|
|
|
|
def pr_str(env; opt):
|
|
(select(.kind == "symbol") | .value) //
|
|
(select(.kind == "string") | .value | if opt.readable then tojson else . end) //
|
|
(select(.kind == "keyword") | ":\(.value)") //
|
|
(select(.kind == "number") | .value | tostring) //
|
|
(select(.kind == "list") | .value | map(pr_str(env; opt)) | join(" ") | "(\(.))") //
|
|
(select(.kind == "vector") | .value | map(pr_str(env; opt)) | join(" ") | "[\(.)]") //
|
|
(select(.kind == "hashmap") | .value | to_entries | _reconstruct_hash | add // [] | map(pr_str(env; opt)) | join(" ") | "{\(.)}") //
|
|
(select(.kind == "nil") | "nil") //
|
|
(select(.kind == "true") | "true") //
|
|
(select(.kind == "false") | "false") //
|
|
(select(.kind == "fn") | "#<fn \(.function)>") //
|
|
(select(.kind == "function")| "#<function \([":anon"] + .names | join(", "))>") //
|
|
(select(.kind == "atom") | "(atom \(env.atoms[.identity] | pr_str(env; opt)))") //
|
|
"#<Unknown \(.kind) in \(.)>";
|
|
|
|
def pr_str(env):
|
|
pr_str(env; {readable: true});
|
|
|
|
def pr_str:
|
|
pr_str(null); # for stepX where X<6 |