popWhile

Pops an input range while a predicate is true. Consumes the input argument.

void
popWhile
(
alias pred
Range
)
(
ref Range range
)
if (
isInputRange!Range &&
is(typeof(unaryFun!pred))
&&
isImplicitlyConvertible!(typeof(unaryFun!pred((ElementType!Range).init)), bool)
)

Parameters

pred

the predicate.

range Range

an input range, must be a lvalue.

Examples

string r0 = "aaaaabcd";
r0.popWhile!"a == 'a'";
assert(r0 == "bcd");

static bool lessTwo(T)(T t)
{
	return t < 2;
}
int[] r1 = [0,1,2,0,1,2];
r1.popWhile!lessTwo;
assert(r1 == [2,0,1,2]);

static bool posLessFive(T)(T t)
{
	return t < 5 && t > 0;
}
int[] r3 = [2,3,4,-1];
r3.popWhile!posLessFive;
assert(r3 == [-1]);
int[] r4 = [2,3,4,5];
r4.popWhile!posLessFive;
assert(r4 == [5]);

Meta