Common Lisp: Convert a list into an alist
This function converts a list of values into an association list (alist).
(defun list->alist (items)
"Convert a list into an alist."
(loop for item from 0 to (1- (length items)) by 2
for key = (nth item items)
for data = (nth (1+ item) items)
nconc (acons key data nil)))
Basic example
Running list->alist
on this input:
(list :key1 "value1" :key2 "value2" :key3 "value3")
produces the following output:
((:key1 . "value1")
(:key2 . "value2")
(:key3 . "value3"))