tisp

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

commit 2740014e6554f18e46fa10a9c858b7764a782948
parent 6c7cee049a49b408da098551121a43e1044e7c68
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Fri, 31 Dec 2021 19:39:45 -0500

Add keep and remove list functions

Diffstat:
Mtib/core.tsp | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tib/core.tsp b/tib/core.tsp @@ -305,12 +305,23 @@ (def (filter proc lst) "Only keep elements of list where applying proc returns true - Also see member, memp" + Also see keep, remove, member, memp" (cond ((not (pair? lst)) Nil) ((proc (car lst)) (cons (car lst) (filter proc (cdr lst)))) (else (filter proc (cdr lst))))) +; TODO keep* remove* +(def (keep elem lst) + "Return list with only elements matching elem + Also see filter, remove" + (filter @(= elem it) lst)) + +(def (remove elem lst) + "Return list without elements matching elem + Also see filter, keep" + (filter @(/= elem it) lst)) + (def (memp proc lst) "Return list of elements after first time procedure applied to each is not nil Also see member, filter"