Write a program using DrRacket
is a member of a list
(member 1 '(2 3 4 1 5)) => true
(member 1 '(2 3 4 (1) 5)) => false
(print (if(member 1 (list 2 3 4 1 5)) 'true 'false))
(print (if(member 1 (list 2 3 4 (list 1) 5)) 'true
'false))
(list 2 3 4 1 5) and (list 2 3 4 (list 1) 5) creates the lists as '(2 3 4 1 5) and '(2 3 4 (1) 5)
member 1 (list 2 3 4 1 5)) and (member 1 (list 2 3 4 (list 1) 5)) determines if 1 is member if lists or not.
1 is member of list '(2 3 4 1 5)
1 is not a member of list '(2 3 4 (1) 5)
Using if true and false are evaluated
(if(member 1 (list 2 3 4 1 5)) 'true 'false))
(if(member 1 (list 2 3 4 (list 1) 5)) 'true 'false))
Output
Get Answers For Free
Most questions answered within 1 hours.