Question: Use DrRacket Implement the following list manipulation procedures. You may find some of them useful in later exercises. Note that for accumulate, the two parameters
Use DrRacket
Implement the following list manipulation procedures. You may find some of them useful in later exercises.
Note that for accumulate, the two parameters in the lamdba represent the first item of the list, and the result of accumulate applied to the rest of the list. So, something like (lambda (x y)... might instead be better named as something like (lambda (first-of-lst result-of-rest)...
- The procedure (contains? list object) takes as arguments a list and an object, and returns #t iff list contains object. Implement two versions of contains?: one recursive with a conditional, and one without a conditional and without (explicit) recursion that uses accumulate and map. (The recursion here is hidden in the implementation of map and accumulate). Hint: The call to map should build a list of boolean values. Use or in the lambda of the accumulate.
Hint:
(define (contains? list object) (accumulate (lambda (x y) ...) ... (map (lambda (x) ...) ...)))
Example:(contains? (list 1 2 3 4) 3) ;Value: #t
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
