Range Type
Bill Baxter
dnewsgroup at billbaxter.com
Mon Mar 24 16:25:06 PDT 2008
Janice Caron wrote:
> On 24/03/2008, Frits van Bommel <fvbommel at remwovexcapss.nl> wrote:
>> > But just to be sure, let's ask the loyal readers of this newsgroup...
>> > Has anyone here ever used opSlice(T,U), where type T != type U? And if
>> > so, for what purpose, and could you live without it?
>>
>> It could probably be used with something like this:
>> <example of end-relative indexing>
>
> You raise a good point. If we're going to allow
>
> auto x = 1..3;
>
> then I guess we should also allow
>
> auto x = 1..$;
>
> Exactly how that should implemented, I'm not sure - but if we get to a
> solution, it will make ranges mighty powerful beasts!
Another very useful thing to have is a notation for the 'everything'
slice. In Python it's just a colon by itself. It's useful for
multi-dimensional arrays:
x[:3,:]
means slice out rows 0-3 of every column.
Used to good effect in NumPy.
--bb
More information about the Digitalmars-d
mailing list