diff options
Diffstat (limited to 'stuff.scm')
-rw-r--r-- | stuff.scm | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -528,6 +528,8 @@ If func approves of one, index-if returns the index that gives that element's po (let ((+documentation+ "(collect-if type func sequence) gathers the elements of sequence that satisfy func, and returns them via type:\n\ (collect-if list integer? #(1.4 2/3 1 1+i 2)) -> '(1 2)")) (lambda (type f sequence) + (unless (sequence? sequence) + (error 'wrong-type-arg "collect-if: sequence arg is ~A" sequence)) (apply type (map (lambda (arg) (if (f arg) arg (values))) sequence))))) ;;; if type=list, this is slightly wasteful because list currently copies its args, so: @@ -539,6 +541,8 @@ If func approves of one, index-if returns the index that gives that element's po (let ((+documentation+ "(remove-if type f sequence) returns via type the elements of sequence that do not satisfy func:\n\ (remove-if list integer? #(1.4 2/3 1 1+i 2)) -> '(1.4 2/3 1+1i)")) (lambda (type f sequence) + (unless (sequence? sequence) + (error 'wrong-type-arg "remove-if: sequence arg is ~A" sequence)) (collect-if type (lambda (obj) (not (f obj))) sequence)))) (define nonce |