adding an element to a list in lisp
- by user272483
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))