diff options
author | Keith Packard <keithp@keithp.com> | 2017-11-17 23:23:50 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-11-17 23:26:59 -0800 |
commit | cf5729a0bae51172f12fc9ec4339d4e975a45fcc (patch) | |
tree | f67bef57d31f5f202718f7e8dbc6f41ac6b6c346 /src/lisp/ao_lisp_const.lisp | |
parent | e1acf5eb12aceda7aa838df031c1da1129d0fa5d (diff) |
altos/lisp: Finish first pass through r7rs
* print -> write, patom -> display
* Add read-char, write-char
* Add exit, current-jiffy, current-second, jiffies-per-second
* Add for-each and string-for-each
* Avoid duplicate builtins with different atoms
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 | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/lisp/ao_lisp_const.lisp b/src/lisp/ao_lisp_const.lisp index d9b1c1f2..191ef005 100644 --- a/src/lisp/ao_lisp_const.lisp +++ b/src/lisp/ao_lisp_const.lisp @@ -463,11 +463,9 @@ (define string (lexpr (chars) (list->string chars))) -(patom "apply\n") +(display "apply\n") (apply cons '(a b)) -(define save ()) - (define map (lexpr (proc lists) (let ((args (lambda (lists) (if (null? lists) () @@ -488,28 +486,30 @@ (apply map proc lists) #t)) -(for-each patom '("hello" " " "world" "\n")) +(for-each display '("hello" " " "world" "\n")) + +(define -string-ml (lambda (strings) + (if (null? strings) () + (cons (string->list (car strings)) (-string-ml (cdr strings)))))) (define string-map (lexpr (proc strings) - (let ((make-lists (lambda (strings) - (if (null? strings) () - (cons (string->list (car strings)) (make-lists (cdr strings)))))) - ) - (list->string (apply map proc (make-lists strings)))))) + (list->string (apply map proc (-string-ml strings)))))) (string-map 1+ "HAL") (define string-for-each (lexpr (proc strings) - (apply string-map proc strings) - #t)) + (apply for-each proc (-string-ml strings)))) + +(string-for-each write-char "IBM\n") -(string-for-each patom "IBM") +(define newline (lambda () (write-char #\newline))) +(newline) (call-with-current-continuation (lambda (exit) (for-each (lambda (x) - (print "test" x) + (write "test" x) (if (negative? x) (exit x))) '(54 0 37 -3 245 19)) |