adding an element to a list in lisp
Posted
by user272483
on Stack Overflow
See other posts from Stack Overflow
or by user272483
Published on 2010-03-29T23:11:14Z
Indexed on
2010/03/29
23:13 UTC
Read the original article
Hit count: 312
i'm using r5rs and i just want to implement a function that returns the intersection of two given lists but i can't do that because i can npot add element to a list. here is my code. how can i fix it? i'm really a beginner in lisp, this is my first work on lisp? thx in advance..
(define list3 '())
(define (E7 list1 list2)
(cond
((null? list1)
list3)
((member (car list1) list2) (append list3 (list (car list1))))
)
(cond
((null? list1)
list3)
((not(null? list1)) (E7 (cdr list1) list2)
)
)
)
(E7 '(4 5) '(3 4))
© Stack Overflow or respective owner