Permalink
Browse files

fixed bug, checking in test file

  • Loading branch information...
1 parent bd8671a commit 4241882d4aabea0605a31233eeb2b354eeed8f75 @krig committed Feb 26, 2012
Showing with 31 additions and 2 deletions.
  1. +3 −2 src/scheme.cpp
  2. +28 −0 src/test.scm
View
@@ -352,7 +352,8 @@ sexpr expand(sexpr x, bool toplevel) {
if (get<sexprs>(&x) == nullptr)
return x; // non-lists pass through
sexprs& xl = get<sexprs>(x);
- REQUIRE(x, xl.size() > 0);
+ if (xl.size() == 0)
+ return xl;
if (is_call_to(xl, "quote")) {
REQUIRE(x, xl.size() == 2);
@@ -851,7 +852,7 @@ void repl(istream& in, bool prompt, bool out) {
sexpr exp = eval(parse(tokens), global_env);
global_env->add("_", exp);
if (out)
- cout << " " << to_str(exp) << endl;
+ cout << to_str(exp) << endl;
}
catch (bad_get& e) {
cerr << "type mismatch: " << diagnostic_information(e) << endl;
View
@@ -0,0 +1,28 @@
+; this is a file with code in it
+
+(def map (lst proc)
+ (if (null? lst) f
+ (do
+ (proc (car lst))
+ (map (cdr lst) proc))))
+
+(def prn (args ...)
+ (map args pr)
+ (pr "\n"))
+
+(defmacro and
+ (fn (args ...)
+ (if (null? args)
+ t
+ (if (== (len args) 1)
+ (car args)
+ `(if ,(car args)
+ (and ,@(cdr args))
+ f)))))
+
+(if (and t 1)
+ (prn "they are both true!"))
+
+(prn "hello")
+(prn (+ 3 5))
+(prn '(+ 3 5))

0 comments on commit 4241882

Please sign in to comment.