Hi.

I'm trying to remove duplicates from a list. 

I have defined the following function:


(defun noduplicates (list)
 (let ((set ()))
   (mapc #'(lambda (x)
         (setq set (adjoin x set :test #'equal)))
      list)
    set))

[17]> (setq b '( 1 2 3 4 5 1 2 3))
(1 2 3 4 5 1 2 3)
[18]> (noduplicates b)
(5 4 3 2 1)

[19]> (setq b '( (1) (2) (3) (4) (5) (1) (2) (3)))
((1) (2) (3) (4) (5) (1) (2) (3))
[20]> (noduplicates b)
((5) (4) (3) (2) (1))


[21]> (setq b '( (1 1) (2 1) (3 1) (4 1) (5 1) (1 1) (2 1) (3 1)))
((1 1) (2 1) (3 1) (4 1) (5 1) (1 1) (2 1) (3 1))
[22]> (noduplicates b)
((5 1) (4 1) (3 1) (2 1) (1 1))

As you can see it works for "simple" lists...
When it comes to a more complex lists it does not work...

(setq z  '((#3A(((3 4 0) (1 3 2) (1 3 2))
       ((1 0 4) (4 0 0) (4 3 1))
       ((2 1 0) (0 1 1) (0 3 3)))
  (0 1915))
 (#3A(((0 2 1) (3 3 4) (3 4 0))
      ((1 3 2) (3 3 1) (0 2 2))
      ((3 1 4) (0 2 2) (1 4 1)))
  (0 1917))
 (#3A(((2 4 0) (4 3 1) (4 1 0))
      ((2 2 1) (4 3 0) (0 3 3))
      ((1 2 0) (0 1 0) (0 2 2)))
  (0 2017))
 (#3A(((3 4 0) (1 3 2) (1 3 2))
      ((1 0 4) (4 0 0) (4 3 1))
      ((2 1 0) (0 1 1) (0 3 3)))
  (0 1915))
 (#3A(((3 4 0) (1 3 2) (1 3 2))
      ((1 0 4) (4 0 0) (4 3 1))
      ((2 1 0) (0 1 1) (0 3 3)))
  (0 1915)))
)


[74]> (noduplicates z)
((#3A(((3 4 0) (1 3 2) (1 3 2))
      ((1 0 4) (4 0 0) (4 3 1))         <== Duplicate  
      ((2 1 0) (0 1 1) (0 3 3)))
  (0 1915))
 (#3A(((3 4 0) (1 3 2) (1 3 2))
      ((1 0 4) (4 0 0) (4 3 1))         <== Duplicate
      ((2 1 0) (0 1 1) (0 3 3)))
  (0 1915))
 (#3A(((2 4 0) (4 3 1) (4 1 0))
      ((2 2 1) (4 3 0) (0 3 3))
      ((1 2 0) (0 1 0) (0 2 2)))
  (0 2017))
 (#3A(((0 2 1) (3 3 4) (3 4 0))
      ((1 3 2) (3 3 1) (0 2 2))
      ((3 1 4) (0 2 2) (1 4 1)))
  (0 1917))
 (#3A(((3 4 0) (1 3 2) (1 3 2))
      ((1 0 4) (4 0 0) (4 3 1))         <== Duplicate
      ((2 1 0) (0 1 1) (0 3 3)))
  (0 1915)))
[75]>

What's going on??  How do I remove the duplicates from the list?


Randy