The OpenD Programming Language

findAmong

Searches the given range for an element that matches one of the given choices.

Advances seq by calling seq.popFront until either find!(pred)(choices, seq.front) is true, or seq becomes empty. Performs O(seq.length * choices.length) evaluations of pred.

For more information about pred see find.

InputRange
findAmong
(
alias pred = "a == b"
InputRange
ForwardRange
)
(
InputRange seq
,
ForwardRange choices
)
if (
isInputRange!InputRange &&
isForwardRange!ForwardRange
)

Parameters

pred

The predicate to use for determining a match.

seq InputRange

The input range to search.

choices ForwardRange

A forward range of possible choices.

Return Value

Type: InputRange

seq advanced to the first matching element, or until empty if there are no matching elements.

Examples

int[] a = [ -1, 0, 1, 2, 3, 4, 5 ];
int[] b = [ 3, 1, 2 ];
assert(findAmong(a, b) == a[2 .. $]);

See Also

Meta