main
Matthew Butterick 10 years ago
parent d2e27edafc
commit 1bb8b90e0b

@ -5,6 +5,8 @@
(module+ test (require rackunit))
(define (count_if pred xs)
;; Count the number of elements of seq for which the predicate is true.
(length (filter-not false? (map pred xs))))
@ -19,4 +21,12 @@
(module+ test
(check-equal? (find_if procedure? (list 3 min max)) min)
(check-equal? (find_if procedure? (list 1 2 3)) null))
(define (every pred xs)
;;;True if every element of seq satisfies predicate.
(andmap pred xs))
(module+ test
(check-true (every procedure? (list min max)))
(check-false (every procedure? (list min 3))))
Loading…
Cancel
Save