aboutsummaryrefslogtreecommitdiff
path: root/rust/src/step2_eval.rs
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-10-27 18:13:45 -0500
committerJoel Martin <github@martintribe.org>2015-01-06 21:58:59 -0600
commita77e2b31de9d1c1f5767e6bff56062f8b3c71211 (patch)
tree1dcf0de2c407510aee4fac2ac5a8dfef7b63c963 /rust/src/step2_eval.rs
parent4ee7c0f2970accc0f49eeac7fb2a0359b159c8ae (diff)
downloadmal-a77e2b31de9d1c1f5767e6bff56062f8b3c71211.tar.gz
mal-a77e2b31de9d1c1f5767e6bff56062f8b3c71211.zip
rust: add step8_macros
Diffstat (limited to 'rust/src/step2_eval.rs')
-rw-r--r--rust/src/step2_eval.rs16
1 files changed, 3 insertions, 13 deletions
diff --git a/rust/src/step2_eval.rs b/rust/src/step2_eval.rs
index 3b27762..f8046b9 100644
--- a/rust/src/step2_eval.rs
+++ b/rust/src/step2_eval.rs
@@ -6,7 +6,7 @@ extern crate regex;
use std::collections::HashMap;
-use types::{MalVal,MalRet,Int,Sym,List,Func,
+use types::{MalVal,MalRet,Int,Sym,List,
_nil,_int,list,func};
mod readline;
mod types;
@@ -58,18 +58,8 @@ fn eval(ast: MalVal, env: &HashMap<String,MalVal>) -> MalRet {
Ok(el) => {
match *el {
List(ref args) => {
- // TODO: make this work
- //match args.as_slice() {
- // [&Func(f), rest..] => {
- // (*f)(rest.to_vec())
- // },
- // _ => Err("attempt to call non-function".to_string()),
- //}
- let args2 = args.clone();
- match *args2[0] {
- Func(f) => f(args.slice(1,args.len()).to_vec()),
- _ => Err("attempt to call non-function".to_string()),
- }
+ let ref f = args.clone()[0];
+ f.apply(args.slice(1,args.len()).to_vec())
}
_ => Err("Invalid apply".to_string()),
}