aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2015-02-16 00:33:30 -0600
committerJoel Martin <github@martintribe.org>2015-02-16 00:33:30 -0600
commit320455465294f170f54cda772142f4de4cb6f602 (patch)
tree43c99b1539f192954f1f7ff18fed2b132c191431
parentd90c784472f6131f28612eb6eaa02404e002178d (diff)
downloadmal-320455465294f170f54cda772142f4de4cb6f602.tar.gz
mal-320455465294f170f54cda772142f4de4cb6f602.zip
miniMAL: keyword, vector and hash-map support.
-rw-r--r--miniMAL/core.json37
-rw-r--r--miniMAL/miniMAL-core.json12
-rw-r--r--miniMAL/printer.json38
-rw-r--r--miniMAL/reader.json35
-rw-r--r--miniMAL/step2_eval.json12
-rw-r--r--miniMAL/step3_env.json12
-rw-r--r--miniMAL/step4_if_fn_do.json12
-rw-r--r--miniMAL/step5_tco.json12
-rw-r--r--miniMAL/step6_file.json12
-rw-r--r--miniMAL/step7_quote.json14
-rw-r--r--miniMAL/step8_macros.json14
-rw-r--r--miniMAL/step9_try.json14
-rw-r--r--miniMAL/stepA_interop.json14
-rw-r--r--miniMAL/types.json94
14 files changed, 275 insertions, 57 deletions
diff --git a/miniMAL/core.json b/miniMAL/core.json
index e61000d..cec9156 100644
--- a/miniMAL/core.json
+++ b/miniMAL/core.json
@@ -11,6 +11,24 @@
["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]]]],
+
["def", "_count", ["fn", ["a"],
["if", ["=", null, "a"],
0,
@@ -46,6 +64,8 @@
["`", "false?"], "false?",
["`", "symbol"], "symbol",
["`", "symbol?"], "symbol?",
+ ["`", "keyword"], "keyword",
+ ["`", "keyword?"], "keyword?",
["`", "pr-str"], ["fn", ["&", "a"], ["pr-list", "a", true, ["`", " "]]],
["`", "str"], ["fn", ["&", "a"], ["pr-list", "a", false, ["`", ""]]],
@@ -72,9 +92,20 @@
["`", "/"], "div",
["`", "time-ms"], "time-ms",
- ["`", "list"], "list",
- ["`", "list?"], "list?",
-
+ ["`", "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",
["`", "nth"], "_nth",
diff --git a/miniMAL/miniMAL-core.json b/miniMAL/miniMAL-core.json
index b885d9b..94fedec 100644
--- a/miniMAL/miniMAL-core.json
+++ b/miniMAL/miniMAL-core.json
@@ -42,15 +42,6 @@
["def", "list", ["fn", ["&", "a"], "a"]],
["def", "list?", ["fn", ["a"], [".", "Array", ["`", "isArray"], "a"]]],
-["def", "assoc!", ["fn", ["a", "b", "c"], ["do", ["set", "a", "b", "c"], "a"]]],
-["def", "assocs!", ["fn", ["hm", "kvs"],
- ["if", ["empty?", "kvs"],
- "hm",
- ["do",
- ["assoc!", "hm", ["get", "kvs", 0], ["get", "kvs", 1]],
- ["assocs!", "hm", ["slice", "kvs", 2]]]]]],
-["def", "hash-map", ["fn", ["&", "a"],
- ["assocs!", ["new", "Object"], "a"]]],
["def", "get", ["fn", ["a", "b"], [".-", "a", "b"]]],
["def", "set", ["fn", ["a", "b", "c"], [".-", "a", "b", "c"]]],
["def", "contains?", ["fn", ["a", "b"], [".", "a", ["`", "hasOwnProperty"], "b"]]],
@@ -97,7 +88,7 @@
["`", "or_FIXME"],
["concat", ["`", ["or"]], ["rest", "xs"]]]]]]]]],
-["def", "typeof", ["fn", ["a"], ["js", ["str", ["`", "typeof "], ["pr-str", "a"]]]]],
+
["def", "repl", ["fn",["prompt", "rep"],
["let", ["r", ["require", ["`", "repl"]],
@@ -113,6 +104,5 @@
[".", "r", ["`", "start"], "opts"]]]],
null
-
]
diff --git a/miniMAL/printer.json b/miniMAL/printer.json
index df2ac82..273d80a 100644
--- a/miniMAL/printer.json
+++ b/miniMAL/printer.json
@@ -7,17 +7,35 @@
[".", ["map", ["fn", ["x"], ["pr-str", "x", "print_readably"]], "exp"],
["`", "join"], ["`", " "]],
["`", ")"]],
+ ["if", ["vector?", "exp"],
+ ["str",
+ ["`", "["],
+ [".", ["map", ["fn", ["x"], ["pr-str", "x", "print_readably"]], "exp"],
+ ["`", "join"], ["`", " "]],
+ ["`", "]"]],
+ ["if", ["map?", "exp"],
+ ["str",
+ ["`", "{"],
+ [".", ["map", ["fn", ["k"],
+ ["str", ["pr-str", "k", "print_readably"],
+ ["`", " "],
+ ["pr-str", ["get", "exp", "k"], "print_readably"]]],
+ ["keys", "exp"]],
+ ["`", "join"], ["`", " "]],
+ ["`", "}"]],
["if", ["=", ["`", "string"], ["type", "exp"]],
- ["if", "print_readably",
- ["str", ["`", "\""],
- [".",
+ ["if", ["=", ["`", "\u029e"], ["get", "exp", 0]],
+ ["str", ["`", ":"], ["slice", "exp", 1]],
+ ["if", "print_readably",
+ ["str", ["`", "\""],
[".",
- [".", "exp",
- ["`", "replace"], ["RegExp", ["`", "\\\\"], ["`", "g"]], ["`", "\\\\"]],
- ["`", "replace"], ["RegExp", ["`", "\""], ["`", "g"]], ["`", "\\\""]],
- ["`", "replace"], ["RegExp", ["`", "\n"], ["`", "g"]], ["`", "\\n"]],
- ["`", "\""]],
- "exp"],
+ [".",
+ [".", "exp",
+ ["`", "replace"], ["RegExp", ["`", "\\\\"], ["`", "g"]], ["`", "\\\\"]],
+ ["`", "replace"], ["RegExp", ["`", "\""], ["`", "g"]], ["`", "\\\""]],
+ ["`", "replace"], ["RegExp", ["`", "\n"], ["`", "g"]], ["`", "\\n"]],
+ ["`", "\""]],
+ "exp"]],
["if", ["=", ["`", "number"], ["type", "exp"]],
"exp",
["if", ["=", null, "exp"],
@@ -34,7 +52,7 @@
["`", " "],
["pr-str", ["get", "exp", ["`", "ast"]]],
["`", ")"]],
- ["str", ["`", "#<unknown: "], "exp", ["`", ">"]]]]]]]]]]]],
+ ["str", ["`", "#<unknown: "], "exp", ["`", ">"]]]]]]]]]]]]]],
["def", "pr-list", ["fn", ["lst", "print_readably", "sep"],
[".", ["map", ["fn", ["s"], ["pr-str", "s", "print_readably"]], "lst"],
diff --git a/miniMAL/reader.json b/miniMAL/reader.json
index 428d12d..e9ea6e1 100644
--- a/miniMAL/reader.json
+++ b/miniMAL/reader.json
@@ -42,31 +42,33 @@
["slice", "token", 1, ["-", ["count", "token"], 1]],
["`", "replace"], ["RegExp", ["`", "\\\\\""], ["`", "g"]], ["`", "\""]],
["`", "replace"], ["RegExp", ["`", "\\\\n"], ["`", "g"]], ["`", "\n"]],
+ ["if", ["=", ["`", ":"], ["get", "token", 0]],
+ ["keyword", ["slice", "token", 1]],
["if", ["=", ["`", "nil"], "token"],
null,
["if", ["=", ["`", "true"], "token"],
true,
["if", ["=", ["`", "false"], "token"],
false,
- ["symbol", "token"]]]]]]]]],
+ ["symbol", "token"]]]]]]]]]],
-["def", "read-list-entries", ["fn", ["rdr"],
+["def", "read-list-entries", ["fn", ["rdr", "start", "end"],
["let", ["tok", ["rdr-peek", "rdr"]],
["if", "tok",
- ["if", ["=", ["`", ")"], "tok"],
+ ["if", ["=", "end", "tok"],
["`", []],
["cons", ["read-form", "rdr"],
- ["read-list-entries", "rdr"]]],
- ["throw", ["`", "expected ')'"]]]]]],
+ ["read-list-entries", "rdr", "start", "end"]]],
+ ["throw", ["str", ["`", "expected "], "end"]]]]]],
-["def", "read-list", ["fn", ["rdr"],
+["def", "read-list", ["fn", ["rdr", "start", "end"],
["let", ["token", ["rdr-next", "rdr"]],
- ["if", ["=", ["`", "("], "token"],
- ["let", ["lst", ["read-list-entries", "rdr"]],
+ ["if", ["=", "start", "token"],
+ ["let", ["lst", ["read-list-entries", "rdr", "start", "end"]],
["do",
["rdr-next", "rdr"],
"lst"]],
- ["throw", ["`", "expected '('"]]]]]],
+ ["throw", ["str", ["`", "expected "], "start"]]]]]],
["def", "read-form", ["fn", ["rdr"],
["let", ["token", ["rdr-peek", "rdr"]],
@@ -90,8 +92,19 @@
["if", ["=", ["`", ")"], "token"],
["throw", ["`", "unexpected ')'"]],
["if", ["=", ["`", "("], "token"],
- ["read-list", "rdr"],
- ["read-atom", "rdr"]]]]]]]]]],
+ ["read-list", "rdr", ["`", "("], ["`", ")"]],
+
+ ["if", ["=", ["`", "]"], "token"],
+ ["throw", ["`", "unexpected ']'"]],
+ ["if", ["=", ["`", "["], "token"],
+ ["vectorl", ["read-list", "rdr", ["`", "["], ["`", "]"]]],
+
+ ["if", ["=", ["`", "}"], "token"],
+ ["throw", ["`", "unexpected '}'"]],
+ ["if", ["=", ["`", "{"], "token"],
+ ["apply", "hash-map", ["read-list", "rdr", ["`", "{"], ["`", "}"]]],
+
+ ["read-atom", "rdr"]]]]]]]]]]]]]],
["def", "read-str", ["fn", ["strn"],
["let", ["tokens", ["tokenize", "strn"],
diff --git a/miniMAL/step2_eval.json b/miniMAL/step2_eval.json
index f5cc113..ee95fe2 100644
--- a/miniMAL/step2_eval.json
+++ b/miniMAL/step2_eval.json
@@ -16,7 +16,17 @@
["throw", ["str", ["`", "'"], "sym", ["`", "' not found"]]]]],
["if", ["list?", "ast"],
["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"],
- "ast"]]]],
+ ["if", ["vector?", "ast"],
+ ["vectorl", ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"]],
+ ["if", ["map?", "ast"],
+ ["let", ["new-hm", ["hash-map"]],
+ ["do",
+ ["map", ["fn", ["k"], ["set", "new-hm",
+ ["EVAL", "k", "env"],
+ ["EVAL", ["get", "ast", "k"], "env"]]],
+ ["keys", "ast"]],
+ "new-hm"]],
+ "ast"]]]]]],
["def", "EVAL", ["fn", ["ast", "env"],
["if", ["not", ["list?", "ast"]],
diff --git a/miniMAL/step3_env.json b/miniMAL/step3_env.json
index 353c3dd..e72de07 100644
--- a/miniMAL/step3_env.json
+++ b/miniMAL/step3_env.json
@@ -14,7 +14,17 @@
["env-get", "env", "ast"],
["if", ["list?", "ast"],
["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"],
- "ast"]]]],
+ ["if", ["vector?", "ast"],
+ ["vectorl", ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"]],
+ ["if", ["map?", "ast"],
+ ["let", ["new-hm", ["hash-map"]],
+ ["do",
+ ["map", ["fn", ["k"], ["set", "new-hm",
+ ["EVAL", "k", "env"],
+ ["EVAL", ["get", "ast", "k"], "env"]]],
+ ["keys", "ast"]],
+ "new-hm"]],
+ "ast"]]]]]],
["def", "LET", ["fn", ["env", "args"],
["if", [">", ["count", "args"], 0],
diff --git a/miniMAL/step4_if_fn_do.json b/miniMAL/step4_if_fn_do.json
index f80ae69..97e8021 100644
--- a/miniMAL/step4_if_fn_do.json
+++ b/miniMAL/step4_if_fn_do.json
@@ -14,7 +14,17 @@
["env-get", "env", "ast"],
["if", ["list?", "ast"],
["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"],
- "ast"]]]],
+ ["if", ["vector?", "ast"],
+ ["vectorl", ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"]],
+ ["if", ["map?", "ast"],
+ ["let", ["new-hm", ["hash-map"]],
+ ["do",
+ ["map", ["fn", ["k"], ["set", "new-hm",
+ ["EVAL", "k", "env"],
+ ["EVAL", ["get", "ast", "k"], "env"]]],
+ ["keys", "ast"]],
+ "new-hm"]],
+ "ast"]]]]]],
["def", "LET", ["fn", ["env", "args"],
["if", [">", ["count", "args"], 0],
diff --git a/miniMAL/step5_tco.json b/miniMAL/step5_tco.json
index 6f7e714..06fd342 100644
--- a/miniMAL/step5_tco.json
+++ b/miniMAL/step5_tco.json
@@ -14,7 +14,17 @@
["env-get", "env", "ast"],
["if", ["list?", "ast"],
["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"],
- "ast"]]]],
+ ["if", ["vector?", "ast"],
+ ["vectorl", ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"]],
+ ["if", ["map?", "ast"],
+ ["let", ["new-hm", ["hash-map"]],
+ ["do",
+ ["map", ["fn", ["k"], ["set", "new-hm",
+ ["EVAL", "k", "env"],
+ ["EVAL", ["get", "ast", "k"], "env"]]],
+ ["keys", "ast"]],
+ "new-hm"]],
+ "ast"]]]]]],
["def", "LET", ["fn", ["env", "args"],
["if", [">", ["count", "args"], 0],
diff --git a/miniMAL/step6_file.json b/miniMAL/step6_file.json
index d85a981..08f22c4 100644
--- a/miniMAL/step6_file.json
+++ b/miniMAL/step6_file.json
@@ -14,7 +14,17 @@
["env-get", "env", "ast"],
["if", ["list?", "ast"],
["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"],
- "ast"]]]],
+ ["if", ["vector?", "ast"],
+ ["vectorl", ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"]],
+ ["if", ["map?", "ast"],
+ ["let", ["new-hm", ["hash-map"]],
+ ["do",
+ ["map", ["fn", ["k"], ["set", "new-hm",
+ ["EVAL", "k", "env"],
+ ["EVAL", ["get", "ast", "k"], "env"]]],
+ ["keys", "ast"]],
+ "new-hm"]],
+ "ast"]]]]]],
["def", "LET", ["fn", ["env", "args"],
["if", [">", ["count", "args"], 0],
diff --git a/miniMAL/step7_quote.json b/miniMAL/step7_quote.json
index 915dc11..78fd49e 100644
--- a/miniMAL/step7_quote.json
+++ b/miniMAL/step7_quote.json
@@ -10,7 +10,7 @@
["def", "READ", ["fn", ["strng"], ["read-str", "strng"]]],
["def", "pair?", ["fn", ["x"],
- ["if", ["list?", "x"],
+ ["if", ["sequential?", "x"],
["if", [">", ["count", "x"], 0], true, false],
false]]],
@@ -34,7 +34,17 @@
["env-get", "env", "ast"],
["if", ["list?", "ast"],
["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"],
- "ast"]]]],
+ ["if", ["vector?", "ast"],
+ ["vectorl", ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"]],
+ ["if", ["map?", "ast"],
+ ["let", ["new-hm", ["hash-map"]],
+ ["do",
+ ["map", ["fn", ["k"], ["set", "new-hm",
+ ["EVAL", "k", "env"],
+ ["EVAL", ["get", "ast", "k"], "env"]]],
+ ["keys", "ast"]],
+ "new-hm"]],
+ "ast"]]]]]],
["def", "LET", ["fn", ["env", "args"],
["if", [">", ["count", "args"], 0],
diff --git a/miniMAL/step8_macros.json b/miniMAL/step8_macros.json
index dad6030..8b93fd0 100644
--- a/miniMAL/step8_macros.json
+++ b/miniMAL/step8_macros.json
@@ -10,7 +10,7 @@
["def", "READ", ["fn", ["strng"], ["read-str", "strng"]]],
["def", "pair?", ["fn", ["x"],
- ["if", ["list?", "x"],
+ ["if", ["sequential?", "x"],
["if", [">", ["count", "x"], 0], true, false],
false]]],
@@ -48,7 +48,17 @@
["env-get", "env", "ast"],
["if", ["list?", "ast"],
["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"],
- "ast"]]]],
+ ["if", ["vector?", "ast"],
+ ["vectorl", ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"]],
+ ["if", ["map?", "ast"],
+ ["let", ["new-hm", ["hash-map"]],
+ ["do",
+ ["map", ["fn", ["k"], ["set", "new-hm",
+ ["EVAL", "k", "env"],
+ ["EVAL", ["get", "ast", "k"], "env"]]],
+ ["keys", "ast"]],
+ "new-hm"]],
+ "ast"]]]]]],
["def", "LET", ["fn", ["env", "args"],
["if", [">", ["count", "args"], 0],
diff --git a/miniMAL/step9_try.json b/miniMAL/step9_try.json
index a00604a..585a1b0 100644
--- a/miniMAL/step9_try.json
+++ b/miniMAL/step9_try.json
@@ -10,7 +10,7 @@
["def", "READ", ["fn", ["strng"], ["read-str", "strng"]]],
["def", "pair?", ["fn", ["x"],
- ["if", ["list?", "x"],
+ ["if", ["sequential?", "x"],
["if", [">", ["count", "x"], 0], true, false],
false]]],
@@ -48,7 +48,17 @@
["env-get", "env", "ast"],
["if", ["list?", "ast"],
["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"],
- "ast"]]]],
+ ["if", ["vector?", "ast"],
+ ["vectorl", ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"]],
+ ["if", ["map?", "ast"],
+ ["let", ["new-hm", ["hash-map"]],
+ ["do",
+ ["map", ["fn", ["k"], ["set", "new-hm",
+ ["EVAL", "k", "env"],
+ ["EVAL", ["get", "ast", "k"], "env"]]],
+ ["keys", "ast"]],
+ "new-hm"]],
+ "ast"]]]]]],
["def", "LET", ["fn", ["env", "args"],
["if", [">", ["count", "args"], 0],
diff --git a/miniMAL/stepA_interop.json b/miniMAL/stepA_interop.json
index b59c67d..44dc33b 100644
--- a/miniMAL/stepA_interop.json
+++ b/miniMAL/stepA_interop.json
@@ -10,7 +10,7 @@
["def", "READ", ["fn", ["strng"], ["read-str", "strng"]]],
["def", "pair?", ["fn", ["x"],
- ["if", ["list?", "x"],
+ ["if", ["sequential?", "x"],
["if", [">", ["count", "x"], 0], true, false],
false]]],
@@ -48,7 +48,17 @@
["env-get", "env", "ast"],
["if", ["list?", "ast"],
["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"],
- "ast"]]]],
+ ["if", ["vector?", "ast"],
+ ["vectorl", ["map", ["fn", ["x"], ["EVAL", "x", "env"]], "ast"]],
+ ["if", ["map?", "ast"],
+ ["let", ["new-hm", ["hash-map"]],
+ ["do",
+ ["map", ["fn", ["k"], ["set", "new-hm",
+ ["EVAL", "k", "env"],
+ ["EVAL", ["get", "ast", "k"], "env"]]],
+ ["keys", "ast"]],
+ "new-hm"]],
+ "ast"]]]]]],
["def", "LET", ["fn", ["env", "args"],
["if", [">", ["count", "args"], 0],
diff --git a/miniMAL/types.json b/miniMAL/types.json
index 0b97db2..5d1e0d3 100644
--- a/miniMAL/types.json
+++ b/miniMAL/types.json
@@ -1,5 +1,6 @@
["do",
+["`", "Utility Functions"],
["def", "_cmp_seqs", ["fn", ["a", "b"],
["if", ["not", ["=", ["count", "a"], ["count", "b"]]],
false,
@@ -10,24 +11,99 @@
false]]]]],
["def", "equal?", ["fn", ["a", "b"],
- ["if", ["list?", "a"],
- ["if", ["list?", "b"],
+ ["if", ["sequential?", "a"],
+ ["if", ["sequential?", "b"],
["_cmp_seqs", "a", "b"],
false],
["if", ["symbol?", "a"],
["=", ["get", "a", ["`", "val"]], ["get", "b", ["`", "val"]]],
["=", "a", "b"]]]]],
+["def", "clone", ["fn", ["obj"],
+ ["if", ["list?", "obj"],
+ ["slice", "obj", 0],
+ ["if", ["vector?", "obj"],
+ ["let", ["new-obj", ["slice", "obj", 0]],
+ ["do",
+ ["set", "new-obj", "__vector?__", true],
+ "new-obj"]],
+ ["if", ["map?", "obj"],
+ ["let", ["new-obj", ["hash-map"]],
+ ["do",
+ ["map", ["fn", ["k"],
+ ["if", [".", "obj", ["`", "hasOwnProperty"], "k"],
+ ["set", "new-obj", "k", ["get", "obj", "k"]],
+ null]],
+ ["keys", "obj"]],
+ "new-obj"]],
+ ["throw", "clone of unsupported type"]]]]]],
+
+["def", "assoc!", ["fn", ["a", "b", "c"], ["do", ["set", "a", "b", "c"], "a"]]],
+["def", "assocs!", ["fn", ["hm", "kvs"],
+ ["if", ["empty?", "kvs"],
+ "hm",
+ ["do",
+ ["assoc!", "hm", ["get", "kvs", 0], ["get", "kvs", 1]],
+ ["assocs!", "hm", ["slice", "kvs", 2]]]]]],
+
+
+["def", "Symbol", ["fn", [], null]],
["def", "symbol", ["fn", ["name"],
- ["hash-map", ["`", "type"], ["`", "Symbol"],
- ["`", "val"], "name"]]],
+ ["assoc!", ["new", "Symbol"], ["`", "val"], "name"]]],
-["def", "symbol?", ["fn", ["obj"],
- ["if", ["=", "obj", null],
- false,
- ["if", ["=", ["`", "Symbol"], ["get", "obj", ["`", "type"]]],
+["def", "symbol?", ["fn", ["a"],
+ ["isa", "a", "Symbol"]]],
+
+
+["def", "keyword", ["fn", ["name"],
+ ["str", ["`", "\u029e"], "name"]]],
+
+["def", "keyword?", ["fn", ["kw"],
+ ["and", ["=", ["`", "string"], ["type", "kw"]],
+ ["=", ["`", "\u029e"], ["get", "kw", 0]]]]],
+
+
+["`", "Override some list defs to account for Vectors"],
+["def", "sequential?", ["fn", ["a"],
+ [".", "Array", ["`", "isArray"], "a"]]],
+
+["def", "list?", ["fn", ["a"],
+ ["if", [".", "Array", ["`", "isArray"], "a"],
+ ["if", [".-", "a", ["`", "__vector?__"]],
+ false,
+ true],
+ false]]],
+
+["def", "empty?", ["fn", ["a"],
+ ["if", ["sequential?", "a"],
+ ["if", ["=", 0, [".-", "a", ["`", "length"]]],
true,
- false]]]],
+ false],
+ ["=", "a", null]]]],
+
+
+["def", "vectorl", ["fn", ["lst"],
+ ["let", ["vec", ["slice", "lst", 0]],
+ ["do",
+ ["set", "vec", ["`", "__vector?__"], true],
+ "vec"]]]],
+
+["def", "vector", ["fn", ["&", "args"], ["vectorl", "args"]]],
+
+["def", "vector?", ["fn", ["a"],
+ ["if", [".", "Array", ["`", "isArray"], "a"],
+ ["if", [".-", "a", ["`", "__vector?__"]],
+ true,
+ false],
+ false]]],
+
+
+["def", "HashMap", ["fn", [], null]],
+["def", "hash-map", ["fn", ["&", "a"],
+ ["assocs!", ["new", "HashMap"], "a"]]],
+["def", "map?", ["fn", ["a"],
+ ["isa", "a", "HashMap"]]],
+
["def", "malfunc", ["fn", ["fn", "ast", "env", "params"],
["hash-map", ["`", "type"], ["`", "MalFunc"],