[color=green];; To me problems like this tend to want to distill down to
;; core problems. Seems to me there are two problems: (1) Find
;; duplicated keys and (2) remove pairs by specifying the keys.
;; As such, I tend to form libraries with discrete functions
;; that perform only one task. Solutions are penned putting
;; together said singularly minded functions ...[/color]
(defun _FindDuplicatedKeys ( pair_lists / n result )
(while pair_lists
(if
(and
(assoc (setq key (caar pair_lists)) (setq pair_lists (cdr pair_lists)))
(null (member key result))
)
(setq result (cons key result))
)
)
result
)
[color=green];; The following is overkill, but in the interests of a
;; somewhat clean, easy to understand, self documenting
;; solution ...[/color]
(defun _RemoveByKeys ( pair_lists keys )
(vl-remove-if
'(lambda (pair) (member (car pair) keys))
pair_lists
)
)
[color=green];; A possible solution ...[/color]
(setq pair_lists '((1 . 2) (1 . 3) (2 . 4)))
(_RemoveByKeys
pair_lists
(_FindDuplicatedKeys pair_lists)
)
=> ((2 . 4))
Overkill? Perhaps.
Verbose? Yup.
Re-usable? Me thinks so.
Cheers.