## digitalmars.D - ndslice: allow: a[ _, 9, R(2, \$, -3)] as matlab's a[: ,9,

Timothee Cour via Digitalmars-d <digitalmars-d puremagic.com> writes:
```i wrote my own tensor library a while ago and it allows the more convenient
matlab/python+numpy like syntax:

a[ _, 9, R(2, \$, -3)]
these are allowed:
R() or _: full range for an index
R(a,b): a..b
R(a,b,s): when s>0, iota(a,b,s)
R(a,b,s): when s<0, iota(a,b,-s).reverse

Could we have this in ndslice?
```
Jan 08 2016
Ilya <ilyayaroshenko gmail.com> writes:
```On Saturday, 9 January 2016 at 00:26:42 UTC, Timothee Cour wrote:
i wrote my own tensor library a while ago and it allows the
more convenient matlab/python+numpy like syntax:

a[ _, 9, R(2, \$, -3)]
these are allowed:
R() or _: full range for an index
R(a,b): a..b
R(a,b,s): when s>0, iota(a,b,s)
R(a,b,s): when s<0, iota(a,b,-s).reverse

Could we have this in ndslice?

Is `a[ _, 9, R(2, \$, -3)]`

equals to

`a[0..\$, 9, 2..\$].reversed!2.strided!2(3)`
or
`a[0..\$, 9, 2..\$].strided!2(3).reversed!2`
?
```
Jan 08 2016
Ilya Yaroshenko <ilyayaroshenko gmail.com> writes:
```On Saturday, 9 January 2016 at 06:20:46 UTC, Ilya wrote:
On Saturday, 9 January 2016 at 00:26:42 UTC, Timothee Cour
wrote:
i wrote my own tensor library a while ago and it allows the
more convenient matlab/python+numpy like syntax:

a[ _, 9, R(2, \$, -3)]
these are allowed:
R() or _: full range for an index
R(a,b): a..b
R(a,b,s): when s>0, iota(a,b,s)
R(a,b,s): when s<0, iota(a,b,-s).reverse

Could we have this in ndslice?

Is `a[ _, 9, R(2, \$, -3)]`

equals to

`a[0..\$, 9, 2..\$].reversed!2.strided!2(3)`
or
`a[0..\$, 9, 2..\$].strided!2(3).reversed!2`
?

My bad. You have already wrote `iota(a,b,-s).reverse`.

We can test this kind of syntax in Mir first
https://github.com/DlangScience/mir
--Ilya
```
Jan 08 2016
Timothee Cour via Digitalmars-d <digitalmars-d puremagic.com> writes:
```After more thought (since you have freedom of redesigning from scratch),
how about this:

https://docs.google.com/document/d/1cEf8AynZEZxlTENJx1i4w1GTB481bbc4iUbUeJT00-U/edit#heading=h.uxrd8sd74w8r

On Fri, Jan 8, 2016 at 11:00 PM, Ilya Yaroshenko via Digitalmars-d <
digitalmars-d puremagic.com> wrote:

On Saturday, 9 January 2016 at 06:20:46 UTC, Ilya wrote:

On Saturday, 9 January 2016 at 00:26:42 UTC, Timothee Cour wrote:

i wrote my own tensor library a while ago and it allows the more
convenient matlab/python+numpy like syntax:

a[ _, 9, R(2, \$, -3)]
these are allowed:
R() or _: full range for an index
R(a,b): a..b
R(a,b,s): when s>0, iota(a,b,s)
R(a,b,s): when s<0, iota(a,b,-s).reverse

Could we have this in ndslice?

Is `a[ _, 9, R(2, \$, -3)]`

equals to

`a[0..\$, 9, 2..\$].reversed!2.strided!2(3)`
or
`a[0..\$, 9, 2..\$].strided!2(3).reversed!2`
?

My bad. You have already wrote `iota(a,b,-s).reverse`.

We can test this kind of syntax in Mir first
https://github.com/DlangScience/mir
--Ilya

```
Jan 08 2016