Print a triangle

Michael Coulombe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 29 06:20:47 PDT 2016


On Friday, 29 April 2016 at 12:01:19 UTC, Joel wrote:
> On Friday, 29 April 2016 at 11:31:51 UTC, rikki cattermole 
> wrote:
>> Not entirely the goal I'm guessing output wise, but this works.
>>
>> import std.range : repeat;
>> foreach(line; 1 .. 11) {
>> 	writeln('#'.repeat(line));
>> }
>
> That is shorter than my foreach version, but I want one that 
> doesn't use foreach in it at all.

Try this:

iota(1,11).each!(a => writeln("#".replicate(a)))


More information about the Digitalmars-d-learn mailing list