aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2016-04-25 17:41:22 -0400
committerbnewbold <bnewbold@robocracy.org>2016-04-25 17:41:22 -0400
commitd824cd25226e040dd432a870de4d3b8655022d72 (patch)
tree4890d7762d9de7a9e71f0acdb75f8c8da8eed7c3
parent6af779121c0124291b52102cf646ea4430c5226f (diff)
downloadspectrum-d824cd25226e040dd432a870de4d3b8655022d72.tar.gz
spectrum-d824cd25226e040dd432a870de4d3b8655022d72.zip
rust: add display and newline builtins
-rw-r--r--rust/spectrum.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/rust/spectrum.rs b/rust/spectrum.rs
index 15c1f7b..097de53 100644
--- a/rust/spectrum.rs
+++ b/rust/spectrum.rs
@@ -13,9 +13,10 @@ use std::collections::HashMap;
//////////// Types and Constants
-// TODO: how to avoid the '34' here?
-const SCHEME_BUILTINS: [&'static str; 34] = [
- "lambda", "quote", "cond", "else", "display",
+// TODO: how to avoid the '35' here?
+const SCHEME_BUILTINS: [&'static str; 35] = [
+ "lambda", "quote", "cond", "else",
+ "display", "newline",
"define", "set!",
"cons", "car", "cdr",
"boolean?", "symbol?", "procedure?", "pair?", "number?", "string?", "null?", "atom?", "zero?",
@@ -544,6 +545,16 @@ fn apply_action(list: &Vec<SchemeExpr>,
_ => Err(format!("cdr takes only lists"))
}
},
+ "display" => {
+ for expr in args {
+ print!("{}", try!(scheme_repr(&expr)));
+ }
+ Ok(SchemeExpr::SchemeNull)
+ },
+ "newline" => {
+ println!("");
+ Ok(SchemeExpr::SchemeNull)
+ },
_ => Err(format!("unimplemented builtin: {}", builtin)),
};
},