Array subscript question [message #19225] |
Thu, 02 March 2000 00:00 |
bowman
Messages: 121 Registered: September 1991
|
Senior Member |
|
|
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 @
|
|
|