Merge pull request #377 from asarhaddon/fix-runtests-pre-eval
[jackhill/mal.git] / miniMAL / step2_eval.json
index f5cc113..cc16f63 100644 (file)
@@ -1,9 +1,9 @@
 ["do",
 
-["load-file", ["`", "miniMAL-core.json"]],
-["load-file", ["`", "types.json"]],
-["load-file", ["`", "reader.json"]],
-["load-file", ["`", "printer.json"]],
+["load", ["`", "miniMAL-core.json"]],
+["load", ["`", "types.json"]],
+["load", ["`", "reader.json"]],
+["load", ["`", "printer.json"]],
 
 ["def", "READ", ["fn", ["strng"],
   ["read-str", "strng"]]],
         ["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"]],
         ["eval-ast", "ast", "env"],
-        ["let", ["el", ["eval-ast", "ast", "env"],
-                 "f", ["first", "el"],
-                 "args", ["rest", "el"]],
-          ["apply", "f", "args"]]]]],
+        ["if", ["empty?", "ast"],
+          "ast",
+          ["let", ["el", ["eval-ast", "ast", "env"],
+                   "f", ["first", "el"],
+                   "args", ["rest", "el"]],
+            ["apply", "f", "args"]]]]]],
 
 ["def", "PRINT", ["fn", ["exp"],
   ["pr-str", "exp", true]]],