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

Home » Public Forums » archive » Splitting An Array Of Strings Without Using Loops
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: Splitting An Array Of Strings Without Using Loops [message #35936 is a reply to message #35881] Mon, 28 July 2003 16:00 Go to previous messageGo to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Mon, 28 Jul 2003 11:24:50 -0700, Rick Towler wrote:


> "Darrick White" wrote...
>
>> It looks like I'm not explaining my problem clearly.
>
>> Is there a way (not knowing what data set input is used) to transform
>> my data into the corresponding result array?
>
> I don't think the issue is one of clarity, but of possibility. Unless
> JD can save you with some magical incarnation of HISTOGRAM you are going
> to have to change your design criteria or use a loop. If performance is
> really that important write this function in C.
>
> -Rick


Come on people. I don't use HISTOGRAM for everything. I use it very
rarely, in fact.

How about something like:

nums=strsplit(strjoin(data,':'),':',/EXTRACT)
cnts=long(total(byte(data) eq 58b,1))+1L

Now you have a list of tuple-counts and the tuples themselves in a long
list. You could (yes) use HISTOGRAM or perhaps many other methods to
stick these into an array as you describe without looping, but rather than
show something you'd forget 5 minutes after dropping it into your code,
I'll join Rick in saying that if parsing these strings quickly is this
important to you, you'll get better results by re-designing the input
format, or pre-parsing them using a language better suited to these
manipulations. And on the off chance that you're suffering from the
"must-optimize-everything-in-sight" disease, you'll want to make sure a
readable and straightforward input loop won't meet your needs before
venturing too far into IDL esoterica:

b=make_array(/LONG,VALUE=-1,max(cnt),n_elements(data))
for i=0,n_elements(data)-1 do b[0,i]=strsplit(data[i],':',/EXTRACT)

Note that there's no integer (long or otherwise) definition of NaN, so I
used -1.

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: where is my plot....
Next Topic: Reading RINEX files into IDL

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

Current Time: Sun Oct 12 14:51:33 PDT 2025

Total time taken to generate the page: 1.03754 seconds