[nem-en] List comprehensions ranges

Kamil Skalski kamil.skalski at gmail.com
Fri May 5 19:38:04 CEST 2006


We had similar request / discussion here
http://nemerle.org/forum/viewtopic.php?t=220
The last post gives some nicer syntax:

for (0 <= i < 3)           // 0, 1, 2
for (0 <= i <= 3)          // 0, 1, 2, 3
for (0 <= i < 7 step 2)    // 0, 2, 4, 6
for (0 <= i < 3 step -1)   // 2, 1, 0

I guess this could be dressed as
foreach (i in $[0 <= i < arr.Length])
   arr [i]

or something similar.

>
> Programming Language Ruby has following syntax.
>
> 0 .. 5  : 1 2 3 4 5
> 0 ... 5 : 1 2 3 4

The problem is that such syntax differences are quite unintuitive and
hard to read...

--
Kamil Skalski
http://nazgul.omega.pl


More information about the devel-en mailing list