Exercise 2.20

Read Exercise 2.20 ~ Solution


accumulate-filter appeared in an earlier exercise, but here I just use the built in raclet procedure filter, which has the same behaviour.

(define (same-parity head . tail)
  (cons head 
        (filter (if (even? head) 
                    even?
                    odd?)
                tail)))

Leave a comment