[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variable stride in array indices



In article <ySg03.87161$A6.43176220@news1.teleport.com>, "DBorland"
<dborland@egi.com> wrote:

> IDL> a[(a[*,2*LINDGEN(3)])[2*LINDGEN(3),*]] = -1
> 
> When you do this, the values from above are set to -1
> IDL> print,a
>           -1           1          -1           3          -1           5
>            6           7           8           9          10          11
>           -1          13          -1          15          -1          17
>           18          19          20          21          22          23
>           -1          25          -1          27          -1          29
>           30          31          32          33          34          35

This only works because the original array was created with LINDGEN.  It
won't work in the general case.

I still like

a[0:*:2,0:*:2] = -1

for aesthetic reasons alone.

Ken