take

Lazily takes only up to n elements of a stream.

take
(
S
)
(,
ulong n
)

Examples

import std.algorithm : equal;
import std.range : iota;
assert([ 1, 2, 4, 8, 16 ].take(3)[].equal([ 1, 2, 4 ]));
assert(iota(31337).take(1024)[].equal(iota(1024)));

Meta