Question: (define (my-filter pred lst) (cond ((null? lst) null) ((not(pred (first lst))) (cons (first lst) (my-filter pred (rest lst)))) (else (my-filter pred (rest lst))))) interactive pane
(define (my-filter pred lst) (cond ((null? lst) null) ((not(pred (first lst))) (cons (first lst) (my-filter pred (rest lst)))) (else (my-filter pred (rest lst)))))
interactive pane input:
(my-filter number? '(1 2 'c 4 #f '(1 2)))
then the result will be this. (list (list 'quote 'c) #false (list 'quote (list 1 2)))
when it should be ('c #f '(1 2))
what is wrong with the code and is it possible to implement the code without using pred?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
