popBackWhile

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

void
popBackWhile
(
alias pred
Range
)
(
ref Range range
)
if (
isBidirectionalRange!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 = "bcdaaaa";
r0.popBackWhile!"a == 'a'";
assert(r0 == "bcd");

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

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

Meta