I have a question about the little schemer for help a How ma

I have a question about the little schemer for help!

a. How many arguments does the function multirember and multirember&co take?

b. Describe how the arguments of multiember and multirember&co are different

Solution

Solution:

A)

1) the function that will be passed initially as ‘col’ (and will be executed last):
(define last-function
(lambda(x y) (length x)))

2) the function called when a matches (car lat):
(define when-match
(lambda (newlat seen) (col newlat (cons (car lat) seen)))

3) the function called when the cond else branch executes:
(define when-differ
(lambda (newlat seen) (col (cons (car lat) newlat) seen))

B) multirember&co:

(define multirember&co
(lambda (a lat col)
(cond
((null? lat)
(col (quote ()) (quote ())))
((eq? (car lat) a)
(multirember&co a
(cdr lat)
(lambda (newlat seen)
(col newlat
(cons (car lat) seen)))))
(else
(multirember&co a
(cdr lat)
(lambda (newlat seen)
(col (cons (car lat) newlat)
seen)))))))

(define last-friend
(lambda (x y)
(length x)))

(display (multirember&co \'tuna \'(strawberries tuna and swordfish) last-friend))

I have a question about the little schemer for help! a. How many arguments does the function multirember and multirember&co take? b. Describe how the argume

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site