comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: indexing arrays with arrays
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: indexing arrays with arrays [message #2431] Fri, 01 July 1994 02:09
robijn is currently offline  robijn
Messages: 18
Registered: June 1994
Junior Member
In article <Cs7sCo.EFB@space.physics.uiowa.edu>,
Larry Granroth <ljg@space.physics.uiowa.edu> wrote:
>
> IDL> a = fltarr(3)
> IDL> map = [1, 1, 2]
> IDL> a(map) = a(map) + [1.0, 2.0, 3.0]
> IDL> print, a
> 0.00000 2.00000 3.00000
>
> [...] I had hoped that "1.0" and "2.0" would
> have been summed into a(1) and "3.0" into a(2), resulting in
> a = [0.0, 3.0, 3.0].
>
> Why doesn't this work?
>

In IDL a(map) is just a three-element array, filled with values of a.
To this temporary variable [1.0, 2.0, 3.0] is added. The last step
is performing the assignment - simply copying the elements of the
temporary array into the corresponding elements of a according to the
left hand side expression. By now IDL already has 'forgotten' what's on
the right hand side. It copies the elements one by one, thus overwriting
a(0) with 2.0.

Frank
--
_____ ____
/ / / Frank Robijn Internet: Robijn@Strw.LeidenUniv.NL
/___ /___/ Sterrewacht Leiden Bitnet: Robijn@HLERUL51
/ / \ Phone (31) 71 275841 Local: Robijn@HL628
/ / \ Fax : (31) 71 275819 Snail: P.O.Box 9513, 2300 RA Leiden,
The Netherlands
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Announcement: Envision 1.1 software available
Next Topic: EXECUTE / ON_ERROR problem, please try this test program.

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 11:46:22 PDT 2025

Total time taken to generate the page: 0.80301 seconds