Question: [RACKET CODING RECURSIVE] (just question 2 please) 1. Write a Racket function (member? x L) that tests whether x E L where L is a
[RACKET CODING RECURSIVE] (just question 2 please)
![[RACKET CODING RECURSIVE] (just question 2 please) 1. Write a Racket function](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f158b65178c_91766f158b5e6657.jpg)
1. Write a Racket function (member? x L) that tests whether x E L where L is a set (represented as a list). (Hint: x E L if and only if either x is equal to the head of L, or x is in the remainder of L.) Test cases: (member? 1 '(3 2 1)) ---> #t (member? 4 '(3 2 1)) ---> #f (member? i '())---> #f (member? 'susan '(susan john ryan)) ---> #t 2. Write a Racket function (subset? L1 L2) that tests whether L, SL . L1 is a subset of L2 if every element of L1 is also a member of L2. Test cases: (subset? '(1 2 3) '(3 2 1))---> #t (subset? '(1 2 3 '(4 5 6)) ---> #f (subset? '(1 2 3) '(1 2 3 4 5 6)) ---> (subset? '(1 2) '()---> #f #t ***Use the function (member? x L) as a helper function in your implementation. 1. Write a Racket function (member? x L) that tests whether x E L where L is a set (represented as a list). (Hint: x E L if and only if either x is equal to the head of L, or x is in the remainder of L.) Test cases: (member? 1 '(3 2 1)) ---> #t (member? 4 '(3 2 1)) ---> #f (member? i '())---> #f (member? 'susan '(susan john ryan)) ---> #t 2. Write a Racket function (subset? L1 L2) that tests whether L, SL . L1 is a subset of L2 if every element of L1 is also a member of L2. Test cases: (subset? '(1 2 3) '(3 2 1))---> #t (subset? '(1 2 3 '(4 5 6)) ---> #f (subset? '(1 2 3) '(1 2 3 4 5 6)) ---> (subset? '(1 2) '()---> #f #t ***Use the function (member? x L) as a helper function in your implementation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
