diff --git a/csp/utils.rkt b/csp/utils.rkt index 6024fa02..510ccd4c 100644 --- a/csp/utils.rkt +++ b/csp/utils.rkt @@ -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)) - \ No newline at end of file + + +(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)))) \ No newline at end of file