Skip to content

Commit

Permalink
Merge baf790c into 98f60f1
Browse files Browse the repository at this point in the history
  • Loading branch information
knobo committed Sep 2, 2018
2 parents 98f60f1 + baf790c commit 36d1398
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/assoc-utils.lisp
Expand Up @@ -34,7 +34,7 @@
alist)
(cons (cons key value) alist))))

(define-setf-expander aget (alist key &environment env)
(define-setf-expander aget (alist key &optional default &environment env)
(multiple-value-bind (dummies vals newvals setter getter)
(get-setf-expansion alist env)
(let ((newval (first newvals)))
Expand All @@ -44,7 +44,7 @@
`(let ((,newval (%aput ,alist ,key ,newval)))
,setter
,newval)
`(aget ,getter ,key)))))
`(aget ,getter ,key ,default)))))

(defun remove-from-alist (alist &rest keys)
(remove-if
Expand Down
5 changes: 5 additions & 0 deletions t/assoc-utils.lisp
Expand Up @@ -22,6 +22,11 @@
(setf (aget alist "address") "Japan")
(is (aget alist "address") "Japan")))

(subtest "(incf aget)"
(let (alist)
(incf (aget alist "value" 0))
(is (aget alist "value") 1)))

(subtest "remove-from-alist & delete-from-alist"
(let ((alist '(("name" . "Eitaro") ("email" . "e.arrows@gmail.com"))))
(is (remove-from-alist alist "name")
Expand Down

0 comments on commit 36d1398

Please sign in to comment.