From d824cd25226e040dd432a870de4d3b8655022d72 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Mon, 25 Apr 2016 17:41:22 -0400 Subject: rust: add display and newline builtins --- rust/spectrum.rs | 17 ++++++++++++++--- 1 file 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, _ => 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)), }; }, -- cgit v1.2.3