Permalink
Browse files

null -> null?, and reverted + procedure to 2-item addition only.

  • Loading branch information...
1 parent 77ce0ed commit d388d91e5f82b1be5cde9ce37db67d97e46e35d7 @mnielsen committed Apr 10, 2012
Showing with 5 additions and 5 deletions.
  1. +3 −3 eval.tl
  2. +2 −2 tiddlylisp.py
View
@@ -7,13 +7,13 @@
(define not (lambda (x) (if x False True)))
(define append (lambda (x y)
- (if (null x) y (cons (car x) (append (cdr x) y)))))
+ (if (null? x) y (cons (car x) (append (cdr x) y)))))
(define pair (lambda (x y) (cons x (cons y (q ()) ))))
(define pairlis
(lambda (x y)
- (if (null x)
+ (if (null? x)
(q ())
(cons (pair (car x) (car y)) (pairlis (cdr x) (cdr y))))))
@@ -45,7 +45,7 @@
(define evlis
(lambda (m a)
- (cond ((null m) (q ()))
+ (cond ((null? m) (q ()))
(True (cons (eval (car m) a) (evlis (cdr m) a))))))
View
@@ -28,7 +28,7 @@ def add_globals(env):
"Add some built-in procedures and variables to the environment."
import operator
env.update(
- {'+': lambda *args: sum(args),
+ {'+': operator.add,
'-': operator.sub,
'*': operator.mul,
'/': operator.div,
@@ -76,7 +76,7 @@ def eval(x, env=global_env):
for (p, e) in x[1:]:
if eval(p, env):
return eval(e, env)
- elif x[0] == 'null': # (null exp)
+ elif x[0] == 'null?': # (null? exp)
(_, exp) = x
return eval(exp,env) == []
elif x[0] == 'if': # (if test conseq alt)

0 comments on commit d388d91

Please sign in to comment.