Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Scheme/DrRacket Help

Name: Anonymous 2012-12-02 15:29

Does anyone know how to do this using one of these: filter, map, foldr? We're not allowed to use recursion.

Write a Scheme function find-common (using at least one abstract list function), which consumes two lists of numbers lst1, and lst2 and produces a list of all elements of lst1 that appear in lst2, with the same order of lst1 . Some examples follow:

(find-common empty empty) => empty

(find-common (list 2 3 56 23 3) (list 3 2 4 56 4 14)) => (list 2 3 56 3)

(find-common (list 56 29) (list 156 329 43)) => empty

Name: Anonymous 2012-12-02 16:19

Is there a way to do this without using lambda?


(define (find-common lst1 lst2)
(filter (lambda (x) (member x lst2)) lst1))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List