My attempt was,
(define (remove-dup lst)
(cond ((null? lst) '())
((null? (cdr lst)) (car lst))
((equal? (car lst) (car (cdr lst))) (remove-dup (cdr lst)))
(else (cons (car lst) (remove-dup (cdr lst))))
)
)
My list was (a b c a a c c c )
What I want is (a b c). Any idea?
Thanks,
I’d approach this by looping with a second list that you build up of seen elements. I’ll feel bad for giving this to you if this was homework though – it’s more important to understand how recursion works than to just have the right answer.
Updated to accommodate your comments – this probably isn’t the cleanest solution but should give you an idea of how it might work.