chickadee » srfi-113 » set-search!

set-search! set element failure successprocedure

The set is searched for element. If it is not found, then the failure procedure is tail-called with two continuation arguments, insert and ignore, and is expected to tail-call one of them. If element is found, then the success procedure is tail-called with the matching element of set and two continuations, update and remove, and is expected to tail-call one of them.

The effects of the continuations are as follows (where obj is any Scheme object):

  • Invoking (insert obj) causes element to be inserted into set.
  • Invoking (ignore obj) causes set to remain unchanged.
  • Invoking (update new-element obj) causes new-element to be inserted into set in place of element.
  • Invoking (remove obj) causes the matching element of set to be removed from it.

In all cases, two values are returned: the possibly updated set and obj.