From 1217f6e1437d33613cf6dbef22d1eaea6bc286a3 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 20 Dec 2017 18:23:44 -0800 Subject: [PATCH] Lambda abstraction --- src/rukka_lang/mod.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rukka_lang/mod.rs b/src/rukka_lang/mod.rs index a19de72..e35ccad 100644 --- a/src/rukka_lang/mod.rs +++ b/src/rukka_lang/mod.rs @@ -135,8 +135,20 @@ impl EvaluatorState { Cons(box mut paramlist, box Cons(box formalexp, box Nil)) => { let mut formal_params = vec![]; { - let mut ptr = &mut paramlist; - + let mut ptr = ¶mlist; + 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 { formal_params,