chickadee » alist-lib » alist-ref/default

alist-ref/default alist key defaultprocedure
alist-ref/default alist key default =procedure

Return a value associated with its key or default.

alist
The alist to search in
key
The key whose value to return
default
The default to return when association doesn't exist
=
The equality predicate to apply to keys
(define alist-ref/default
  (case-lambda
    ((alist key default) (alist-ref alist key (lambda () default)))
    ((alist key default =) (alist-ref alist key (lambda () default) =))))