tisp

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

commit e4b259efae04c47b72de3e39e1e1045f83eab9a6
parent 4f23a8d4c6d830f5e25c6ffd8d45fadf34b1bc5d
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Fri, 31 Dec 2021 19:54:24 -0500

Add every? and everyp? list functions

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

diff --git a/tib/core.tsp b/tib/core.tsp @@ -340,6 +340,18 @@ Also see memp, filter" (memp @(= elem it) lst)) +(def (everyp? proc lst) + "Return boolean if every element in list passes proc" + (if (pair? lst) + (if (proc (car lst)) + (everyp? proc (cdr lst)) + False) + True)) + +(def (every? elem lst) + "Return boolean if every element in list is equal to elem" + (everyp? @(= elem it) lst)) + (def (compose . procs) "Create function made from chaining procedures given" (cond @@ -373,7 +385,7 @@ (cons (cons (car x) (car y)) (zip (cdr x) (cdr y)))))) -; define English list element accessors +; English list element accessors (def rest cdr) ; TODO first and rest are generics for list, vec, str types (def first car) ; TODO rename func to new name (recur f ((n 1)