Check element is in list or not Scheme

You have problems, and we're glad to hear them. Explain the problem, what you have tried, and where you got stuck.
Feel free to share a little info on yourself and the course.
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.

Check element is in list or not Scheme

Postby lastpeony » Thu Apr 26, 2018 10:32 am

I am trying to write a function which is checking whether element is in list(return true) or not(return false.)


Code: Select all
(define in? (lambda ('el lst)
(cond ((member el lst '#t) (else '#f)))

))



(in? 3 '(2 5 3))


In this case my expected output is #t but i get Error: execute: unbound symbol: "el" [in?] error.

another test case is :

Code: Select all
 (in? 2 ’(1 (2) 5))

my expected output is #f
lastpeony
 
Posts: 2
Joined: Thu Apr 26, 2018 10:22 am

Return to Homework

Who is online

Users browsing this forum: No registered users and 2 guests

cron