chickadee » srfi-113 » bag-search!

bag-search! bag element failure successprocedure

The bag 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 bag 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 bag.
  • Invoking (ignore obj) causes bag to remain unchanged.
  • Invoking (update new-element obj) causes new-element to be inserted into bag in place of element.
  • Invoking (remove obj) causes the matching element of bag to be removed from it.

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