aboutsummaryrefslogtreecommitdiff
path: root/rust/src/step9_try.rs
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-10-27 23:20:22 -0500
committerJoel Martin <github@martintribe.org>2015-01-06 21:59:01 -0600
commit77b2da6cf337bbd85914619bfbccba69b6621a04 (patch)
treeafa9bcca8e965363962d585f312cb76eb14f8183 /rust/src/step9_try.rs
parentbd3067230dcbd18fb1f0db7abb52c4ea1c2e227b (diff)
downloadmal-77b2da6cf337bbd85914619bfbccba69b6621a04.tar.gz
mal-77b2da6cf337bbd85914619bfbccba69b6621a04.zip
rust: add conj, stepA. Self-hosting!
Diffstat (limited to 'rust/src/step9_try.rs')
-rw-r--r--rust/src/step9_try.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/rust/src/step9_try.rs b/rust/src/step9_try.rs
index 6e3cf29..c36abcb 100644
--- a/rust/src/step9_try.rs
+++ b/rust/src/step9_try.rs
@@ -151,7 +151,7 @@ fn eval_ast(ast: MalVal, env: Env) -> MalRet {
}
}
Ok(match *ast { List(_,_) => list(ast_vec),
- _ => vector(ast_vec) })
+ _ => vector(ast_vec) })
},
Hash_Map(ref hm,_) => {
let mut new_hm: HashMap<String,MalVal> = HashMap::new();
@@ -440,6 +440,8 @@ fn main() {
let _ = rep("(def! *host-language* \"rust\")", repl_env.clone());
let _ = rep("(def! not (fn* (a) (if a false true)))", repl_env.clone());
let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env.clone());
+ let _ = rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))", repl_env.clone());
+ let _ = rep("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))", repl_env.clone());
// Invoked with command line arguments
let args = os::args();