I am trying to write a function that removes all duplicate integers and sublists from a list input. My current code is as follows:
(define (nested-reduce lst)
(cond
[(empty? lst) '()]
[(member (car lst) (cdr lst)) (cons (car lst) (nested-reduce (remove (car lst) (cdr lst))))]
;[lst] ;check lst status
[(list? (car lst))
(letrec ([search-and-reduce
(lambda (x)
(cond
[(empty? x) '()]
[(member (car x) (cdr x)) (cons (car lst) (search-and-reduce (remove (car lst) (cdr lst))))]
)
)])
(search-and-reduce (car lst)))
]
)
)
(nested-reduce '(1 3 (2 5) (2 5) (2 5 (2 5) (2 5)) 3 7 1)) ;should return (1 3 (2 5) (2 5 (2 5)) 7).
When I run it, I get '(1 3 (2 5) . #<void>). What should I do? Please reply at your earliest convenience.