Thread overview
D's equivalent List Comprehension
Dec 13, 2019
Jesse Phillips
Dec 13, 2019
mipri
Dec 14, 2019
Jesse Phillips
December 13, 2019
I had mentioned my take on list comprehension here:

https://forum.dlang.org/post/qslt0q$2dnb$1@digitalmars.com#post-ycbohbqaygrgmidyhjma:40forum.dlang.org

However someone put together a more comprehensive tutorial of its power. So I took the opportunity to demonstrate the parallel in D.

https://dev.to/jessekphillips/list-comprehension-in-d-4hpi

D is like writing English. Wait I thought that was supposed to be Python, maybe I am thinking ruby.
December 13, 2019
On Friday, 13 December 2019 at 15:20:02 UTC, Jesse Phillips wrote:
> I had mentioned my take on list comprehension here:
>
> https://forum.dlang.org/post/qslt0q$2dnb$1@digitalmars.com#post-ycbohbqaygrgmidyhjma:40forum.dlang.org
>
> However someone put together a more comprehensive tutorial of its power. So I took the opportunity to demonstrate the parallel in D.
>
> https://dev.to/jessekphillips/list-comprehension-in-d-4hpi
>
> D is like writing English. Wait I thought that was supposed to be Python, maybe I am thinking ruby.

It might help your blog posts to use drepl in your examples:

https://code.dlang.org/packages/drepl

A session:

$ dub -q run drepl
Welcome to D REPL.
D> import std;
std
D> iota(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
D> [2,45,21,45]
[2, 45, 21, 45]
D> [2,45,21,45].enumerate.assocArray
[0:2, 3:45, 2:21, 1:45]
D> iota(10).filter!(i => i % 2 == 0)
[0, 2, 4, 6, 8]
D>

Lines without a semicolon are expressions, whose values are
printed automatically. Lines with semicolons can import stuff,
declare variables, define new functions, etc. Serious current
limitations are: it's not aware of dub and can't import dub
packages, and it can't parse dstyle braces.

December 14, 2019
On Friday, 13 December 2019 at 15:35:24 UTC, mipri wrote:
>
> It might help your blog posts to use drepl in your examples:
>
> https://code.dlang.org/packages/drepl
>

That is nice. Is there a web frontend? Right    now I am using run.dlang.io from my phone. Prior to that I didn't compile anything.