I am using Intermediate Student with Lambda in DrRacket, I was wondering how one would remove the duplicates in a list, while keeping the order. For example (remo
hmm i just had a racket exam recently, :/
the 'standard' remove-duplicates
works fine but i was using pretty-big in drRacket so it had to be loaded using (require racket/list)
here is an alternative way :)
using mutation (not really in the spirit of racket but.. it works.)
(define (set l)
(define the-set '())
(begin (for-each
(lambda (x)
(if (member x the-set)
#t
(set! the-set (cons x the-set))))
l)
(reverse the-set)))
hope this helps... cheers!