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

Home » Public Forums » archive » Re: Array subscript question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Array subscript question [message #19223 is a reply to message #19222] Thu, 02 March 2000 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Kenneth P. Bowman (bowman@null.edu) writes:

> 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]

Uh, I'm sure it's doing the operation three times, Ken.
But always to the same value. :-)

Sounds what you want is a loop. I'm not too fond
of them in IDL, but certainly it's appropriate here.
I think the answer to your question really is this:
array subscripting operations are NOT loops!

FOR I=0,2 DO a[2] = a[2] + 10.0

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Radon Transform
Next Topic: Re: IDL and 3D Image

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

Current Time: Fri Oct 10 03:08:44 PDT 2025

Total time taken to generate the page: 0.39330 seconds