Better slicing
Lionello Lunesu
lio at remove.lunesu.com
Wed Mar 8 23:47:21 PST 2006
To reverse an array is a costly operation, and it would not be a good idea
to hide it behind a fancy operator, it will hide the penalty.
L.
"NN" <NN_member at pathlink.com> wrote in message
news:dun61g$30be$1 at digitaldaemon.com...
> What about more powerful slicing, like e.g. in Python ?
>
> char[] x;
>
> char[] y = x[0 : x.size : 1];
> char[] y = x[x.size : 1]; // Same
>
> char[] z = x[x.size : 0 : -1]; // Reverse
> char[] z = x[x.size :: -1]; // Same
>
> // Maybe with D syntax
> char[] x;
>
> char[] y = x[0 .. x.size .. 1];
> char[] y = x[x.size .. 1]; // Same
>
> char[] z = x[x.size .. 0 .. -1]; // Reverse
> char[] z = x[x.size .. .. -1]; // Same
>
>
More information about the Digitalmars-d
mailing list