assoc-utils

https://github.com/fukamachi/assoc-utils.git

git clone 'https://github.com/fukamachi/assoc-utils.git'

(ql:quickload :assoc-utils)
12

Assoc-Utils

Build Status Coverage Status Quicklisp dist

Utilities for manipulating association lists.

Usage

aget

(defvar *person*
  '(("name" . "Eitaro") ("email" . "e.arrows@gmail.com")))

(aget *person* "name")
;=> "Eitaro"

(aget *person* "address")
;=> NIL

(aget *person* "address" "Tokyo, Japan")
;=> "Tokyo, Japan"

(setf (aget *person* "name") "Eitaro Fukamachi")

*person*
;=> (("name" . "Eitaro") ("email" . "e.arrows@gmail.com"))

remove-from-alist & delete-from-alist

(defvar *person*
  '(("name" . "Eitaro") ("email" . "e.arrows@gmail.com")))

(remove-from-alist *person* "name")
;=> (("email" . "e.arrows@gmail.com"))

;; Destructive version
(delete-from-alist *person* "name")
;=> (("email" . "e.arrows@gmail.com"))

alist-plist & plist-alist

(defvar *person*
  '(("name" . "Eitaro") ("email" . "e.arrows@gmail.com")))

(alist-plist *person*)
;=> (:NAME "Eitaro" :EMAIL "e.arrows@gmail.com")

(plist-alist '(:name "Eitaro" :email "e.arrows@gmail.com"))
;=> (("name" . "Eitaro") ("email" . "e.arrows@gmail.com"))

alist-keys & alist-values

(defvar *person*
  '(("name" . "Eitaro") ("email" . "e.arrows@gmail.com")))

(alist-keys *person*)
;=> ("name" "email")

(alist-values *person*)
;=> ("Eitaro" "e.arrows@gmail.com")

alistp

(alistp '(("name" . "Eitaro") ("email" . "e.arrows@gmail.com")))
;=> T

(alistp 1)
;=> NIL

(alistp nil)
;=> T

;; Type: alist is also available
(typep '(("name" . "Eitaro") ("email" . "e.arrows@gmail.com")) 'alist)
;=> T

alist=

(alist= '(("name" . "Eitaro") ("email" . "e.arrows@gmail.com"))
        '(("email" . "e.arrows@gmail.com") ("name" . "Eitaro")))
;=> T

Installation

(ql:quickload :assoc-utils)

Author

License

Assoc-Utils is free and unencumbered software released into the public domain.