CLCS
Function

acons

acons key datum alistnew-alist

Arguments and Values

keyan object.
datuman object.
alistan association list.
new-alistan association list.

Description

Creates a fresh cons, the cdr of which is alist and the car of which is another fresh cons, the car of which is key and the cdr of which is datum.

Examples

 (setq alist '()) ⇒  NIL
 (acons 1 "one" alist) ⇒  ((1 . "one"))
 alist ⇒  NIL
 (setq alist (acons 1 "one" (acons 2 "two" alist))) ⇒  ((1 . "one") (2 . "two"))
 (assoc 1 alist) ⇒  (1 . "one")
 (setq alist (acons 1 "uno" alist)) ⇒  ((1 . "uno") (1 . "one") (2 . "two"))
 (assoc 1 alist) ⇒  (1 . "uno")

Notes

(acons key datum alist) ≡ (cons (cons key datum) alist)