The Python version: sum(item * item for item in sequence)
can be translated to English as: "Sum of (item * item) foreach item in sequence" While the D version: reduce!("a+b")(map!("a*a")(sequence), 0); looks to me like: Reduce! a plus b map! a times a (sequence) (and a random 0 here). On Sun, Oct 3, 2010 at 12:59 PM, Andrei Alexandrescu < seewebsiteforem...@erdani.org> wrote: > On 10/03/2010 10:37 AM, bearophile wrote: > >> Peter Alexander: >> >> Out of curiosity, what syntax did you propose? >>> >> >> >> http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=73868 >> >> >> >> That said, the current D way of writing it isn't all that different >>> from Python: >>> >>> return reduce!("a+b")(map!("a*a")(sequence), 0); >>> >> >> That's many times worse than the Python syntax. >> > > This entails there's a way to measure that. How? > > > Array/range comprehensions are syntax sugar, their point is to give >> something clean and readable that helps chunking: >> http://en.wikipedia.org/wiki/Chunking_%28psychology%29 >> > > You'd need to bring a pointer to a document that confirms that (and how) > array and range comprehensions have helping chunking as their point. I > googled for > > array comprehensions help chunking > > to no avail. > > > Andrei >