map

Lazily iterates the given range and calls the given callable for each element.

map
(
alias callable
Range
)
(
Range range
)
if (
isInputRange!(Unqual!Range) &&
isCallableWith!(callable, ElementType!Range)
)

Return Value

Type: auto

a range containing the result of each call to callable

Examples

enum a = [1, 2, 3, 4].staticArray;
enum expected = [2, 4, 6, 8].staticArray;

enum result = a[].map!(e => e * 2);
static assert(result.equal(expected[]));

Meta