RSS Feed

Lisp Project of the Day


You can support this project by donating at:

Donate using PatreonDonate using Liberapay

Or see the list of project sponsors.


Tests 😀
CI 😀

This is a small utility library by Eitaro Fukamachi. It serves a single purpose - make working with alists more convenient.

The library has good documentation with lots of examples. Here is the excerpt from it:

POFTHEDAY> (defvar *person*
             '(("name" . "Eitaro")
               ("email" . "")))

POFTHEDAY> (assoc-utils:aget *person* "name")

POFTHEDAY> (assoc-utils:aget *person* "address")

POFTHEDAY> (assoc-utils:aget *person* "address"
                             ;; This is default
                             "Tokyo, Japan")
"Tokyo, Japan"

;; The alist remains the same
POFTHEDAY> *person*
(("name" . "Eitaro") ("email" . ""))

;; But aget is setf-able:
POFTHEDAY> (setf (assoc-utils:aget *person* "address")
                 "Tokyo, Japan")

POFTHEDAY> *person*
(("address" . "Tokyo, Japan")
 ("name" . "Eitaro")
 ("email" . ""))

POFTHEDAY> (assoc-utils:delete-from-alistf *person*
(("address" . "Tokyo, Japan")
 ("name" . "Eitaro"))

There are also conversion functions which automatically converts keys from strings to keywords and vice versa:

POFTHEDAY> *person*
(("address" . "Tokyo, Japan") 
 ("name" . "Eitaro"))

POFTHEDAY> (assoc-utils:alist-plist *person*)
(:ADDRESS "Tokyo, Japan"
 :NAME "Eitaro")

POFTHEDAY> (assoc-utils:plist-alist *)
(("address" . "Tokyo, Japan")
 ("name" . "Eitaro"))

Read the documentation to learn more about other functions which allow to compare alists, check their type and to get keys and values.

Brought to you by 40Ants under Creative Commons License