next up previous contents
Next: Searching Arrays Up: Searching Functions Previous: Best String Match

Ordered Searches

Calling Sequence:
SearchOrderedArray(target, L)
Parameters:
target : { string, real}
L : { list, array}

Returns: {0, posint }

Synopsis: The SearchOrderedArray function returns the first index i such that $L[i] \leq target < L[i+1]$.

Examples:

> SearchOrderedArray(5, [2, 4, 6, 8, 10]);
> SearchOrderedArray('mike', ['chantal', 'gaston', 'mike', 'ulrike', 'xianghong']);
> SearchOrderedArray(5, [10, 8, 6, 4, 2]);             # the list is unordered.




Gaston Gonnet
1998-09-15