Even more concise

This commit is contained in:
greg 2017-12-10 19:01:44 -08:00
parent 3386fcc505
commit 5e7aef1040

View File

@ -82,17 +82,13 @@ impl EvaluatorState {
expr @ NumberAtom(_) => expr,
True => True,
False => False,
Cons(box operator, box operands) => {
match operator {
SymbolAtom(sym) => match &sym[..] {
"quote" | "eq?" | "cons" | "car" | "cdr" | "atom?" |
"define" | "lambda" | "if" | "cond" => self.eval_special_form(&sym[..], operands)?,
_ => {
let evaled = self.eval(SymbolAtom(sym))?;
self.apply(evaled, operands)?
}
},
_ => unimplemented!()
Cons(box operator, box operands) => match operator {
SymbolAtom(ref sym) if match &sym[..] {
"quote" | "eq?" | "cons" | "car" | "cdr" | "atom?" | "define" | "lambda" | "if" | "cond" => true, _ => false
} => self.eval_special_form(sym, operands)?,
_ => {
let evaled = self.eval(operator)?;
self.apply(evaled, operands)?
}
},
Nil => Nil,