Print a triangle
Joel via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Apr 29 04:23:30 PDT 2016
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);
More information about the Digitalmars-d-learn
mailing list