Word description Performs a binary search on a sequence, calling the quotation to decide whether to end the search (+eq+), search lower (+lt+) or search higher (+gt+).
If the sequence is non-empty, outputs the index and value of the closest match, which is either an element for which the quotation output +eq+, or failing that, the least element for which the quotation output +lt+, or if there were none of the above, the greatest element for which the quotation output +gt+.
Notes If the sequence has at least one element, this word always outputs a valid index, because it finds the closest match, not necessarily an exact one. In this respect its behavior differs from find.
Examples Searching for an integer in a sorted array: