tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | LICENSE

commit 49174e20cfaa071931f5b5b19d43f0e01e22a412
parent 58a0240520c7974cb02184d4e6738094484daec3
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Tue, 24 Dec 2019 00:54:53 -0800

Define English list element accessors

Diffstat:
tibs/lib.tsp | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/tibs/lib.tsp b/tibs/lib.tsp @@ -177,6 +177,17 @@ (define (member mem lst) (memp (lambda (x) (= mem x)) lst)) +; define English list element accessors +(define rest cdr) ; TODO first and rest are generics for list, vec, str types +(define first car) +(let (((def name count) + (list 'define (list name 'x) (list 'nth 'x count)))) + (recur f ((n 1) + (lst '(second third forth fifth sixth seventh eighth ninth tenth))) + (when lst + (eval (def (car lst) n)) + (f (+ n 1) (cdr lst))))) + ;;; Stacks (define (push stack val) (cons val stack))