Until

Lazily iterates range until the element e for which pred(e, sentinel) is true.

This is similar to takeWhile in other languages.

Constructors

this
this(Range input, Sentinel sentinel, OpenRight openRight)
this
this(Range input, OpenRight openRight)

Members

Functions

popFront
void popFront()

Properties

empty
bool empty [@property getter]
front
auto ref front [@property getter]
save
Until save [@property getter]

Parameters

pred

Predicate to determine when to stop.

Return Value

An input range that iterates over the original range's elements, but ends when the specified predicate becomes true. If the original range is a forward range or higher, this range will be a forward range.

Examples

import std.algorithm.comparison : equal;
import std.typecons : No;
int[] a = [ 1, 2, 4, 7, 7, 2, 4, 7, 3, 5];
assert(equal(a.until(7), [1, 2, 4]));
assert(equal(a.until(7, No.openRight), [1, 2, 4, 7]));

Meta