Even more concise

This commit is contained in:
greg 2017-12-10 19:01:44 -08:00
parent 8493233b69
commit d11500c643
1 changed files with 7 additions and 11 deletions

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,