Print operation
This commit is contained in:
parent
7f546fa879
commit
8f6c80ac8c
@ -23,6 +23,7 @@ impl EvaluatorState {
|
|||||||
default_map.insert(format!("<"), Primitive(Less));
|
default_map.insert(format!("<"), Primitive(Less));
|
||||||
default_map.insert(format!("<="), Primitive(LessThanOrEqual));
|
default_map.insert(format!("<="), Primitive(LessThanOrEqual));
|
||||||
default_map.insert(format!(">="), Primitive(GreaterThanOrEqual));
|
default_map.insert(format!(">="), Primitive(GreaterThanOrEqual));
|
||||||
|
default_map.insert(format!("display"), Primitive(Display));
|
||||||
|
|
||||||
EvaluatorState {
|
EvaluatorState {
|
||||||
binding_stack: vec![default_map],
|
binding_stack: vec![default_map],
|
||||||
@ -282,7 +283,7 @@ enum Sexp {
|
|||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
enum PrimitiveFn {
|
enum PrimitiveFn {
|
||||||
Plus, Minus, Mult, Div, Mod, Greater, Less, GreaterThanOrEqual, LessThanOrEqual
|
Plus, Minus, Mult, Div, Mod, Greater, Less, GreaterThanOrEqual, LessThanOrEqual, Display
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrimitiveFn {
|
impl PrimitiveFn {
|
||||||
@ -291,6 +292,12 @@ impl PrimitiveFn {
|
|||||||
use self::PrimitiveFn::*;
|
use self::PrimitiveFn::*;
|
||||||
let op = self.clone();
|
let op = self.clone();
|
||||||
Ok(match op {
|
Ok(match op {
|
||||||
|
Display => {
|
||||||
|
for arg in evaled_operands {
|
||||||
|
print!("{}\n", arg.print());
|
||||||
|
}
|
||||||
|
Nil
|
||||||
|
},
|
||||||
Plus | Mult => {
|
Plus | Mult => {
|
||||||
let mut result = match op { Plus => 0, Mult => 1, _ => unreachable!() };
|
let mut result = match op { Plus => 0, Mult => 1, _ => unreachable!() };
|
||||||
for arg in evaled_operands {
|
for arg in evaled_operands {
|
||||||
|
Loading…
Reference in New Issue
Block a user