Page 1 of 1

Check element is in list or not Scheme

Posted: Thu Apr 26, 2018 10:32 am
by lastpeony
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