I understand that (eq '(3 . d) '(3 . d)) returns nil, and (eq 3 3) returns t. But I do not understand why delq is deleting one (3 . d) in the second example each loop when y is (3 . d). Is mapc placing some type of invisible symbol on one of the (3 . d) but not the others such that only one (1) of them in the sequence is eq?
(let* ((original '(0 1 2 3 3 3 3 4 5 6))
(copy (copy-list original)))
(mapc (lambda (x)
(mapc (lambda (y)
(message "y: %s | copy: %s" y copy)
(setq copy (delq y copy)))
copy))
original))
In the second example, one (3 . d) is deleted each loop when y is (3 . d).
(let* ((original '((0 . a) (1 . b) (2 . c) (3 . d) (3 . d)
(3 . d) (3 . d) (4 . e) (5 . f) (6 . g)))
(copy (copy-list original)))
(mapc (lambda (x)
(mapc (lambda (y)
(message "y: %s | copy: %s" y copy)
(setq copy (delq y copy)))
copy))
original))
Note: copy-sequence is an alternative to copy-list a.k.a. cl-copy-list (defined in cl.el).