Function to print a diamond shape
monarch_dodra
monarchdodra at gmail.com
Thu Mar 20 15:08:30 PDT 2014
On Thursday, 20 March 2014 at 21:25:03 UTC, Ali Çehreli wrote:
> What interesting, boring, efficient, slow, etc. ways are there?
>
> Ali
I'd be interested in seeing a solution using "iota", and the
currently proposed "each" or "tee". A quick protype to draw a
triangle would be:
iota(0, n).each!(a=>q{%(*%)}.writefln(a.iota()))();
or
iota(0, n).each!(a=>'*'.repeat(a).writeln())();
Adapting that to do a diamond should be straight forward? It
would be a good benchmark of functional vs imperative code, and
the usability of "each".
More information about the Digitalmars-d-learn
mailing list