;;; Examples of tallying. Fun fun fun.
(define tally
(lambda (pred? lst)
(cond
((null? lst) 0)
((pred? (car lst)) (+ 1 (tally pred? (cdr lst))))
(else (tally pred? (cdr lst))))))
(define make-tallier
(lambda (pred?) ; The parameter to make-tallier
; Return a new procedure of one parameter, lst
(lambda (lst)
(tally pred? lst))))
(define count
(lambda (pred?)
(letrec ((counter
(lambda (lst)
(cond
((null? lst) 0)
((pred? (car lst)) (+ 1 (counter (cdr lst))))
(else (counter (cdr lst)))))))
counter)))