Problem 2: Filter Lst (100 pts)
Write a procedure filter-lst
, which takes a predicate fn
and a list lst
, and returns a new list containing only elements of the list that satisfy the predicate. The output should contain the elements in the same order that they appeared in the original list.
(define (filter-lst fn lst)
'YOUR-CODE-HERE
)
;;; Tests
; scm> (filter-lst even? '(0 1 1 2 3 5 8))
; (0 2 8)