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

Home » Public Forums » archive » Replication question
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
Replication question [message #45490] Wed, 14 September 2005 16:09
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
Hey guys,

I know there's got to be an easy way to do this, but my brain is cramped
up right now. Given an array input, I'd like to output an array where
the index of the of the input array is replicated by the corresponding
value in the input array. The input array will always contain positive
values.

For example...
input: [1, 2, 1, 4]
output: [0, 1, 1, 2, 3, 3, 3, 3]

input: [3, 3, 3, 1]
output: [0, 0, 0, 1, 1, 1, 2, 2, 2, 3]

I know that I could loop over my input array, replicate the loop
variable by the value of the input array at each position and
concatenate the resulting arrays, but this solution does not seem like
"The IDL Way". Any dimensional jugglers out there know a nice looking
solution?

-Mike
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Force Field
Next Topic: Will IDL divide up processing on a Beowolf cluster like it does on an SMP machine

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

Current Time: Wed Oct 08 17:29:54 PDT 2025

Total time taken to generate the page: 0.00584 seconds