diff --git a/csp/utils.rkt b/csp/utils.rkt index a48d6a62..4b88ea4f 100644 --- a/csp/utils.rkt +++ b/csp/utils.rkt @@ -1,3 +1,12 @@ #lang racket/base +(require racket/list racket/bool) -(provide (all-defined-out)) \ No newline at end of file +(provide (all-defined-out)) + +(module+ test (require rackunit)) + +(define (count_if pred xs) + (length (filter-not false? (map pred xs)))) + +(module+ test + (check-equal? (count_if procedure? (list 42 null max min)) 2)) \ No newline at end of file