;;; [X -> Y] Y [List-of X] -> [List-of Y]
;;; Use op to fold all the elements of the input list together.
;;; (list x1 ... xn) -> (op x1 (op x2 ... (op xn base)))
(define (my-foldr op base xs)
(cond [(empty? xs) base]
[else (op (first xs)
(my-foldr op base (rest xs)))]))
;;; [X -> Y] [List-of X] -> [List-of Y]
;;; Apply op to each element of input list and collect the results.
(define (my-map op xs)
(cond [(empty? xs) empty]
[else (cons (op (first xs))
(my-map op (rest xs)))]))
;;; [X -> Boolean] [List-of X] -> [List-of X]
;;; Apply the test to each element of the input list, and collect the winners.
(define (my-filter good? xs)
(cond [(empty? xs) empty]
;; Keep the first element.
[(good? (first xs))
(cons (first xs)
(my-filter good? (rest xs)))]
;; Drop the first element.
[else (my-filter good? (rest xs)))]