add not, if.

This commit is contained in:
Jan Nieuwenhuizen 2016-07-10 13:04:10 +02:00
parent bfed3eb8b3
commit f373e5ae76
2 changed files with 18 additions and 0 deletions

11
scm.mes
View file

@ -64,3 +64,14 @@
((null? r) (cons (f (car l)) (map f (cdr l)))) ((null? r) (cons (f (car l)) (map f (cdr l))))
((null? (cdr r)) ((null? (cdr r))
(cons (f (car l) (caar r)) (map f (cdr l) (cdar r)))))) (cons (f (car l) (caar r)) (map f (cdr l) (cdar r))))))
(define (not x)
(cond (x #f)
(#t #t)))
(define-macro (if expr then . else)
(cond ((not (eq? (c:eval expr (current-module)) #f))
then)
(#t
(cond ((pair? else) (car else))
(#t *unspecified*)))))

View file

@ -124,4 +124,11 @@
(display (= 3 '3)) (display (= 3 '3))
(newline) (newline)
(display (if #t 'true))
(newline)
(display (if (eq? 0 '0) 'true 'false))
(newline)
(display (if (= 1 2) 'true 'false))
(newline)
'() '()