chickadee » integer-map » fxmapping-find

fxmapping-find pred fxmap failure #!optional successprocedure

pred is a predicate of type fixnum * → boolean. failure is a procedure of type [] → * …. If the optional success parameter is supplied, then it must be a procedure of type fixnum * → * …. success defaults to values.

Invokes success in tail context on k and v and returns it results, where (k, v) is the association of fxmap with the least key such that (pred k v) is true. If there is no such association, then failure is tail-called with no arguments and its results are returned.

Examples:

(fxmapping-find (lambda (_ v) (even? v))
                (fxmapping 0 1 1 2 2 4 3 8)
                (lambda () (values #f #f)))
 ⇒ 1 2

(fxmapping-find (lambda (_ v) (negative? v))
                (fxmapping 0 1 1 2 2 4 3 8)
                (lambda () (values 'nope 'nada)))
 ⇒ nope nada

(fxmapping-find (lambda (k s) (= k (string-length s)))
                (fxmapping 2 "worf" 3 "data" 4 "troi")
                (lambda () (error "not found"))
                list)
 ⇒ (4 "troi")