Closed xianrenb closed 9 years ago
Ranges can already do exactly those things. See http://nbviewer.ipython.org/gist/pao/dbd0a405a56afd6dbfa2
(and a special thanks to http://tmpnb.org for making this example straightforward to create)
This is exactly the problem. Ranges are not the same as arrays! I believe we need to be able to create array of ranges in a concise way. For example, "[1:5, 1:3]" should be an array of two ranges: "1 to 5" and "1 to 3". Range(s) between "[" and "]" should still be range(s). Currently, we could convert range to array: "convert(Array, 1:5)" would give "[1, 2, 3, 4, 5]". "[1:5]" should not equal "[1, 2, 3, 4, 5]".
There are already several issues discussing this, which you have linked to – why open a duplicate issue intentionally?
Simple, because this is a new syntax. It may or may not be related to other issues.
New syntax is not something that should be added lightly.
You can create an array of ranges using
UnitRange[1:3, 1:5]
Dense range vectors should be avoided, so I don't think they deserve
special syntax. Something like collect(a:b)
is enough.
I would suggest that new syntax "a..b" represents "[a, a+1, a+2, ... , b]". The followings should then become true: "1..5" represents "[1, 2, 3, 4, 5]". "reverse(1..5)" represents "[5, 4, 3, 2, 1]". "1..99[1:2:end]" represents "[1, 3, 5, 7, ..., 99]".
Related issue: #3737