MultidimArray.byFunction

Returns a forward range which has mutable elements for iteration using indices defined by pred starting from a = 0 and incrementing it while indices are in valid range.

struct MultidimArray(T, size_t n)
@property
byFunction
(
string pred
)
()
if (
n >= 1
)

Examples

auto matrix = multidimArray!char(30, 20);
matrix[] = ' ';

foreach(ref el; matrix.byFunction!`a, a`) // fills a diagonal
	el = 'X';

foreach(ref el; matrix.byFunction!`a^^2 / 5, a`()) // fills a parabola points
	el = 'Y';

import std.stdio;
writeln(matrix);

Meta