Ruby-style "each" in D?
monarch_dodra
monarchdodra at gmail.com
Thu Mar 20 15:32:11 PDT 2014
On Wednesday, 19 March 2014 at 15:06:40 UTC, Andrei Alexandrescu
wrote:
> Pros and cons are already being discussed. Destroy!
>
> https://github.com/D-Programming-Language/phobos/pull/2024
>
>
> Andrei
User Ali Çehreli has posted in learn what I think is an
interesting problem:
http://forum.dlang.org/thread/lgfmbf$v7c$1@digitalmars.com
//----
This is a somewhat common little exercise: Write a function that
takes
the size of a diamond and produces a diamond of that size.
When printed, here is the output for size 11:
*
***
*****
*******
*********
***********
*********
*******
*****
***
*
What interesting, boring, efficient, slow, etc. ways are there?
Ali
//----
The reason I bring it up is that this usually leads to a
competition of whoever thinks up the most creative/concise UFCS
chain.
So here's what I'm thinking: Let's do this, but also using
each/tee/tap/consume/walk (and others?)!
I think this "real world" scenario is a good bench for seeing the
effects of mixing imperative-style statements into a
functional-style wrapper.
Maybe the result will reveal that something is awesome, or that
it is useless? That maybe something that looks like it works, is
actually subtly buggy? That maybe each turns out to be useful
past our wildest dreams?
Who knows?
More information about the Digitalmars-d
mailing list