chickadee » alist-lib » alist-update!/default

alist-update!/default alist key function defaultprocedure
alist-update!/default alist key function default =procedure

On analogy with hash-table-update!, descructively update an association.

alist
The alist to update
key
The key associated with the update
f
A monadic function taking the preƫxisting key
default
The default value if no association exists
=
The equality predicate for keys
(define alist-update!/default
  (case-lambda
    ((alist key function default)
     (alist-update!/default alist key function default eqv?))
    ((alist key function default =)
     (alist-update! alist key function (lambda () default)))))