Lambda abstraction

This commit is contained in:
greg 2017-12-20 18:23:44 -08:00
parent 6f41167402
commit 1217f6e143

View File

@ -135,8 +135,20 @@ impl EvaluatorState {
Cons(box mut paramlist, box Cons(box formalexp, box Nil)) => { Cons(box mut paramlist, box Cons(box formalexp, box Nil)) => {
let mut formal_params = vec![]; let mut formal_params = vec![];
{ {
let mut ptr = &mut paramlist; let mut ptr = &paramlist;
loop {
match ptr {
&Cons(ref arg, ref rest) => {
if let SymbolAtom(ref sym) = **arg {
formal_params.push(sym.clone());
ptr = rest;
} else {
return Err(format!("Bad lambda format"));
}
},
_ => break,
}
}
} }
FnLiteral { FnLiteral {
formal_params, formal_params,