On 29/04/2016 11:23 PM, Joel wrote:
What is a quick way to print a triangle? I'm thinking without foreach,
not like I have here.
foreach(line; iota(1, 10 + 1)) {
writeln("#".replicate(line));
}
These don't work:
iota(1, 10 + 1).
tee!((a) => { writeln("#".replicate(a)); });
string result;
iota(1, 10 + 1).
tee!((a) => result ~= "#".replicate(a) ~ "\n");
writeln(result);
Not entirely the goal I'm guessing output wise, but this works.
import std.range : repeat;
foreach(line; 1 .. 11) {
writeln('#'.repeat(line));
}