diff options
author | Keith Packard <keithp@keithp.com> | 2017-11-16 17:49:47 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-11-16 18:40:31 -0800 |
commit | b3b4731fcb89cb404433f37a7704a503567c43bd (patch) | |
tree | 74f0a214725905c7556a735127f01a4b4b0926be /src/lisp/ao_lisp_const.lisp | |
parent | bd881a5b85d7cd4fb82127f92f32e089499b50cb (diff) |
altos/lisp: Add scheme-style bools (#t and #f)
Cond and while compare against #f, just like scheme says to.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp/ao_lisp_const.lisp')
-rw-r--r-- | src/lisp/ao_lisp_const.lisp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/lisp/ao_lisp_const.lisp b/src/lisp/ao_lisp_const.lisp index 3c8fd21b..df277fce 100644 --- a/src/lisp/ao_lisp_const.lisp +++ b/src/lisp/ao_lisp_const.lisp @@ -95,7 +95,7 @@ ; (setq make-names (lambda (vars) - (cond (vars + (cond ((not (null? vars)) (cons (car (car vars)) (make-names (cdr vars)))) ) @@ -108,7 +108,7 @@ ; expressions to evaluate (setq make-exprs (lambda (vars exprs) - (cond (vars (cons + (cond ((not (null? vars)) (cons (list set (list quote (car (car vars)) @@ -127,7 +127,7 @@ ; of nils of the right length (setq make-nils (lambda (vars) - (cond (vars (cons nil (make-nils (cdr vars)))) + (cond ((not (null? vars)) (cons () (make-nils (cdr vars)))) ) ) ) @@ -149,13 +149,14 @@ ) ) +(let ((x 1)) x) + ; boolean operators (def or (lexpr (l) - (let ((ret nil)) - (while l - (cond ((setq ret (car l)) - (setq l nil)) + (let ((ret #f)) + (while (not (null? l)) + (cond ((car l) (setq ret #t) (setq l ())) ((setq l (cdr l))))) ret ) @@ -164,14 +165,16 @@ ; execute to resolve macros -(or nil t) +(or #f #t) (def and (lexpr (l) - (let ((ret t)) - (while l - (cond ((setq ret (car l)) + (let ((ret #t)) + (while (not (null? l)) + (cond ((car l) (setq l (cdr l))) - ((setq ret (setq l nil))) + (#t + (setq ret #f) + (setq l ())) ) ) ret @@ -181,4 +184,4 @@ ; execute to resolve macros -(and t nil) +(and #t #f) |