Question: 4-write a recursive scheme function COMPARE-LISTS? that compare two lists and return a list of common elements. For example: ( COMPARE-LISTS? '(A B C) (D
4-write a recursive scheme function COMPARE-LISTS? that compare two lists and return a list of common elements. For example: ( COMPARE-LISTS? '(A B C) (D (A B) C) ) should return true. (A C)
5- write a recursive scheme function SUB-LISTS that returns all the possible sub- lists of a simple list. For example: SUB-LISTS (A B C) ) should return (), (A), (B), (C), (A B), (A C), (B C), and (A B C). Please note that simple list is a list that doesn't have any sublist.
6- Write a recursive scheme function EXP-DEPTH that returns the depth of the most nested parentheses in a list. (EXP-DEPTH 'A) is 0, (EXP-DEPTH '( )) is 1, (EXP-DEPTH '(1 2 3) ) should return 1. (EXP-DEPTH '( J ((K) L) M)) should re- turn 3, since the element K is nested in three levels of parentheses.
*Please note that you are allowed to use tions in Q4,Q5, and Q6. CDR, CAR, CONS, LIST, COND, LIST?, EQ?, EQV? , and NULL?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
