list contains implemented
This commit is contained in:
parent
da0709c4db
commit
b638918a89
7 changed files with 36 additions and 9 deletions
|
|
@ -85,3 +85,18 @@ this will continue iuntil the list is exhausted.'
|
|||
(set (q result) (func result current))
|
||||
(set (q list-iter) (pop remaining)))))
|
||||
result))
|
||||
|
||||
(def contains?
|
||||
'Takes two arguments: a list and an element.
|
||||
Returns true if the list contains the element.'
|
||||
(list elem)
|
||||
(let ((found false)
|
||||
(list-iter (pop list)))
|
||||
(while (and (gt? (len list-iter) 1)
|
||||
(not found))
|
||||
(let ((current (car list-iter))
|
||||
(remaining (cdr list-iter)))
|
||||
(if (eq? current elem)
|
||||
(set (q found) true)
|
||||
(set (q list-iter) (pop remaining)))))
|
||||
found))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue