Scheme List Methods
3. Write a methodcalled isMember that returns true if an element is a member of alist. False otherwise. (write your own).
(isMember ‘(1 2 3 4 32 1) 3) => #t
(isMember ‘(1 2 3 4 32 1) 8) => #f
4. Use the isMember method to create a new method calleddifferenceOfSets to create a new list, List C, that contains allelements in List A that are not in List B. i.e. C = A – B
(differenceOfSets ‘(12 3 4 5 6 7 8 9) ‘(1 3 5)) => (2 4 6 7 8 9)
5. The procedureslist-ref and list-tail return the nth element and nth tail of alist ls. Write both methods.
(list-ref ‘(1 2 3 4)0) => 1
(list-ref ‘(1 2 3 4)1) => 2
(list-tail ‘(1 2 3 4)0) => (1 2 3 4)
(list-tail ‘(1 2 3 4)1) => (2 3 4)
(list-ref ‘(a short(nested) list) 2) => (nested)
(list-tail ‘(a short(nested) list) 2) => ((nested) list)
Expert Answer
Answer to Scheme List Methods 3. Write a method called isMember that returns true if an element is a member of a list. False other…