Name: Anonymous 2012-08-17 12:56
(define (removerepeated l)
(cond (case (null? l)
(list))
(case (inlist (cdr l) (car l))
(removerepeated (cdr l)))
(else (cons (car l) (removerepeated (cdr l))))))l is a list. The procedure is supposed to turn a list l into a set. Yes I know a primitive set exists in Scheme. This is just a data structures exercise I'm doing.
Anyway I run this:
(display (removerepeated (list 1 2 3 4 1 2 3 4 4 3 2 1)))And get this
()Questions:
1. Can anyone hint out what is wrong with my snippet of piss poor code?
2. I use (list) to denote an empty list. I this good technique or is there an ulterior way that is more conventional?
3. How does one debug Scheme code? I don't usually use debuggers, just printf and equivalent.