tisp

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

commit 2c5affc676759954b723c5267aadfcf81540451d
parent ab055d71ddf82410dc2209d96701b21decf39a69
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Thu,  1 Aug 2019 17:45:04 -0700

Add append assoc and member list functions

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

diff --git a/tibs/lib.tsp b/tibs/lib.tsp @@ -102,6 +102,19 @@ (map fn (cdr lst)))) (else ()))) +(define (append l1 l2) + (cond ((nil? l1) l2) + (else (cons (car l1) (append (cdr l1) l2))))) + +(define (assoc key table) + (cond ((nil? table) ()) + ((= key (caar table)) (car table)) + (else (assoc key (cdr table))))) + +(define (member? mem lst) + (cond ((nil? lst) ()) + ((= mem (car lst)) t) + (else (member? mem (cdr lst))))) ;;; Math (define pi (* 4 (arctan 1.)))