Replace item in association list in elisp

With alists, you usually add a new cons in front of the old one to “shadow” the old value, like so:

(add-to-list 'a1 '(:k1 10))

After you do this (assoc :k1 a1) will return 10.

If you want to “undo” your change so assoc again returns your old value, use this code:

(setq a1 (delq (assoc :k1 a1) a1))

This will remove the FIRST match for :k1 from a1.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)