Re: Print a triangle

2016-04-29 Thread Joel via Digitalmars-d-learn
[snip] On Friday, 29 April 2016 at 13:20:47 UTC, Michael Coulombe wrote: Try this: iota(1,11).each!(a => writeln("#".replicate(a))) Yes, this is what I was looking for! It's my birthday today.

Re: Print a triangle

2016-04-29 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Apr 29, 2016 at 11:45:39AM -0700, H. S. Teoh via Digitalmars-d-learn wrote: [...] > Unfortunately, due to some silly autodecoding issues in Phobos, > byCodeUnit is a necessary hack to make this work. I'll file a bug for > this. [...] https://issues.dlang.org/show_bug.cgi?id=15972 T --

Re: Print a triangle

2016-04-29 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Apr 29, 2016 at 12:01:19PM +, Joel via Digitalmars-d-learn 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) { > >

Re: Print a triangle

2016-04-29 Thread Michael Coulombe via Digitalmars-d-learn
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

Re: Print a triangle

2016-04-29 Thread Joel via Digitalmars-d-learn
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

Re: Print a triangle

2016-04-29 Thread rikki cattermole via Digitalmars-d-learn
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(

Print a triangle

2016-04-29 Thread Joel via Digitalmars-d-learn
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 resul