summaryrefslogtreecommitdiff
path: root/src/lisp
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-11-18 22:00:44 -0800
committerKeith Packard <keithp@keithp.com>2017-11-18 22:00:44 -0800
commit12a1f6ad48f2b924f71239effeb90afca75a090f (patch)
treeda4d42d66f10698b5f38c0bc9b60cf1f01fa7b02 /src/lisp
parent5f8f0ed5cd5d4b4f793c602ed09f9b4bdb98f7e8 (diff)
altos/lisp: Fix some scheme compat issues
flush -> flush-output nth -> list-ref (oh, and add list-tail) add let* (same as let for now) write control chars in octal make hanoi example work Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp')
-rw-r--r--src/lisp/ao_lisp_builtin.c4
-rw-r--r--src/lisp/ao_lisp_builtin.txt2
-rw-r--r--src/lisp/ao_lisp_const.lisp16
-rw-r--r--src/lisp/ao_lisp_string.c5
4 files changed, 19 insertions, 8 deletions
diff --git a/src/lisp/ao_lisp_builtin.c b/src/lisp/ao_lisp_builtin.c
index ccd13d07..e5370f90 100644
--- a/src/lisp/ao_lisp_builtin.c
+++ b/src/lisp/ao_lisp_builtin.c
@@ -533,9 +533,9 @@ ao_lisp_do_string_to_list(struct ao_lisp_cons *cons)
}
ao_poly
-ao_lisp_do_flush(struct ao_lisp_cons *cons)
+ao_lisp_do_flush_output(struct ao_lisp_cons *cons)
{
- if (!ao_lisp_check_argc(_ao_lisp_atom_flush, cons, 0, 0))
+ if (!ao_lisp_check_argc(_ao_lisp_atom_flush2doutput, cons, 0, 0))
return AO_LISP_NIL;
ao_lisp_os_flush();
return _ao_lisp_bool_true;
diff --git a/src/lisp/ao_lisp_builtin.txt b/src/lisp/ao_lisp_builtin.txt
index 4c484337..c324ca67 100644
--- a/src/lisp/ao_lisp_builtin.txt
+++ b/src/lisp/ao_lisp_builtin.txt
@@ -31,7 +31,7 @@ f_lexpr less_equal <=
f_lexpr greater_equal >=
f_lambda list_to_string list->string
f_lambda string_to_list string->list
-f_lambda flush
+f_lambda flush_output flush-output
f_lambda delay
f_lexpr led
f_lambda save
diff --git a/src/lisp/ao_lisp_const.lisp b/src/lisp/ao_lisp_const.lisp
index 191ef005..861a4fc8 100644
--- a/src/lisp/ao_lisp_const.lisp
+++ b/src/lisp/ao_lisp_const.lisp
@@ -60,10 +60,17 @@
(defun caddr (l) (car (cdr (cdr l))))
-(defun nth (list n)
- (cond ((= n 0) (car list))
- ((nth (cdr list) (1- n)))
- )
+(define list-tail (lambda (x k)
+ (if (zero? k)
+ x
+ (list-tail (cdr x (- k 1)))
+ )
+ )
+ )
+
+(define list-ref (lambda (x k)
+ (car (list-tail x k))
+ )
)
; simple math operators
@@ -264,6 +271,7 @@
(let ((x 1)) x)
+(define let* let)
; boolean operators
(define or (lexpr (l)
diff --git a/src/lisp/ao_lisp_string.c b/src/lisp/ao_lisp_string.c
index fff218df..1daa50ea 100644
--- a/src/lisp/ao_lisp_string.c
+++ b/src/lisp/ao_lisp_string.c
@@ -140,7 +140,10 @@ ao_lisp_string_write(ao_poly p)
printf ("\\t");
break;
default:
- putchar(c);
+ if (c < ' ')
+ printf("\\%03o", c);
+ else
+ putchar(c);
break;
}
}