takeBackWhile

Returns a lazy input range that takes from the input tail while a predicate is verified and the input is not empty.

takeBackWhile
(
alias pred
Range
)
(
auto 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 bidirectional range, only consumed when passed by reference.

Examples

import std.range: array;
import std.ascii: isDigit;
auto r = "A123";
assert(takeBackWhile!((a) => isDigit(a))(r).array == "321");
assert(r == "A");
assert(takeBackWhile!((a) => isDigit(a))(r).array == "");
assert(takeBackWhile!((a) => isDigit(a))("").array == "");

Meta