[nem-en] List comprehensions ranges
Sandro Magi
smagi at springairsystems.com
Fri May 5 20:31:47 CEST 2006
Fore completeness: in mathematics, '[' is inclusive, and '(' is
exclusive. Thus:
(0 .. 5)
1,2,3,4
[0 .. 5)
0,1,2,3,4
[0 .. 5]
0,1,2,3,4,5
Although the syntax proposed below is easier to parse.
Sandro
Kamil Skalski wrote:
> 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
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
More information about the devel-en
mailing list