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

Array subscript question



Can someone explain this behavior to me?  I can't find anything in the
documentation that states that repeated subscripts are handled
differently.

IDL> a = FINDGEN(5)
IDL> i = [1, 2, 3]
IDL> a[i] = a[i] + 10.0
IDL> PRINT, a
      0.00000      11.0000      12.0000      13.0000      4.00000

This is the behavior I expect.


IDL> a = FINDGEN(5)
IDL> i = [2, 2, 2]
IDL> a[i] = a[i] + 10.0
IDL> PRINT, a
      0.00000      1.00000      12.0000      3.00000      4.00000

Why does it only do the operation *once* when
IDL> HELP, a[i]
<Expression>    FLOAT     = Array[3]



IDL> a = FINDGEN(5)
IDL> i = [2, 2, 2]
IDL> a[i] = a[i] + [10.0, 10.0, 10.0]
IDL> PRINT, a
      0.00000      1.00000      12.0000      3.00000      4.00000

Even this doesn't help.

Ken

-- 
Dr. Kenneth P. Bowman, Professor                409-862-4060
Department of Meteorology                       409-862-4466 fax
Texas A&M University                            bowmanATcsrp.tamu.edu
College Station, TX   77843-3150                Replace AT with @