From 77b2da6cf337bbd85914619bfbccba69b6621a04 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Mon, 27 Oct 2014 23:20:22 -0500 Subject: rust: add conj, stepA. Self-hosting! --- rust/src/step9_try.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'rust/src/step9_try.rs') 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 = 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(); -- cgit v1.2.3