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);
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.