I wrote a simple intersection function on two lists:
(define (intersection l1 l2)
(if (null? l1) '()
(if (member (car l1) l2)
(cons (car l1) (intersection (cdr l1) l2))
(intersection (cdr l1) l2))))
But I can't get replace this code so that (intersection (cdr l1) l2) only appears once as in:
(define (intersection l1 l2)
(if (null? l1) '()
(let (appel '(intersection (cdr l1) l2))
(if (member (car l1) l2)
(cons (car l1) appel)
appel))))
I try also to replace appel with (eval appel) but it didn' work.
appeland missing parentheses in theletform.appelin theletform does not need to be quoted, and an extra pair of parentheses need to be put around that binding.