Even more concise
This commit is contained in:
parent
8493233b69
commit
d11500c643
@ -82,17 +82,13 @@ impl EvaluatorState {
|
|||||||
expr @ NumberAtom(_) => expr,
|
expr @ NumberAtom(_) => expr,
|
||||||
True => True,
|
True => True,
|
||||||
False => False,
|
False => False,
|
||||||
Cons(box operator, box operands) => {
|
Cons(box operator, box operands) => match operator {
|
||||||
match operator {
|
SymbolAtom(ref sym) if match &sym[..] {
|
||||||
SymbolAtom(sym) => match &sym[..] {
|
"quote" | "eq?" | "cons" | "car" | "cdr" | "atom?" | "define" | "lambda" | "if" | "cond" => true, _ => false
|
||||||
"quote" | "eq?" | "cons" | "car" | "cdr" | "atom?" |
|
} => self.eval_special_form(sym, operands)?,
|
||||||
"define" | "lambda" | "if" | "cond" => self.eval_special_form(&sym[..], operands)?,
|
_ => {
|
||||||
_ => {
|
let evaled = self.eval(operator)?;
|
||||||
let evaled = self.eval(SymbolAtom(sym))?;
|
self.apply(evaled, operands)?
|
||||||
self.apply(evaled, operands)?
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => unimplemented!()
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Nil => Nil,
|
Nil => Nil,
|
||||||
|
Loading…
Reference in New Issue
Block a user