array slicing currently does not support steps?

mw mingwu at gmail.com
Mon Aug 3 23:32:29 UTC 2020


Hi,

I just noted that D array slice does not support steps?

https://dlang.org/articles/d-array-article.html


Ever since Python 1.4, the slicing syntax has supported an 
optional third ``step'' or ``stride'' argument. For example, 
these are all legal Python syntax: L[1:10:2], L[:-1:1], L[::-1]. 
This was added to Python at the request of the developers of 
Numerical Python, which uses the third argument extensively.

https://docs.python.org/2.3/whatsnew/section-slices.html

>>> L = range(10)
>>> L[::2]
[0, 2, 4, 6, 8]


Shall we add a DIP for this?



More information about the Digitalmars-d mailing list