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

Home » Public Forums » archive » Getting rid of loops
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
Getting rid of loops [message #18932] Thu, 17 February 2000 00:00 Go to next message
Jacob Noel-Storr is currently offline  Jacob Noel-Storr
Messages: 1
Registered: February 2000
Junior Member
I am trying to create non-loopy IDL code for a project I am working on.

I have a very long list of integers ('cycle numbers') and I need some way of
creating an array that consists of just the cycle numbers. For example if I
had:

> cycles=[2,2,2,2,2,6,6,7,7,7,9,9,9,27,27,27]

then I would want a function which would do this kid of thing:

> print,fn(cycles)
[2,6,7,9,27]

At the moment this is done by looping through the data twice. Once to count
how many different values there are and once to write the different values
into an array.

Any suggestions about how this could be achieved without the two 'for'
loops?

Thanks,
Jacob

--
Jacob Noel-Storr
Astronomy Department
Columbia University / Biosphere 2 Center
www.astro.bio2.edu/jacob/
jake@astro.columbia.edu
Re: Getting rid of loops [message #19216 is a reply to message #18932] Fri, 03 March 2000 00:00 Go to previous message
Nando Iavarone is currently offline  Nando Iavarone
Messages: 48
Registered: December 1998
Member
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Jacob Noel-Storr wrote:
<blockquote TYPE=CITE>I am trying to create non-loopy IDL code for a project
I am working on.
<p>I have a very long list of integers ('cycle numbers') and I need some
way of
<br>creating an array that consists of just the cycle numbers. For example
if I
<br>had:
<p>> cycles=[2,2,2,2,2,6,6,7,7,7,9,9,9,27,27,27]
<p>then I would want a function which would do this kid of thing:
<p>> print,fn(cycles)
<br>[2,6,7,9,27]</blockquote>
if your repeated values are adjacent, you can use
<br>the "uniq" function.
<br>&nbsp;
<pre>--&nbsp;
Nando Iavarone
Advanced Computer System - SPACE DIVISION
via Lazzaro Belli, 23
00040&nbsp; Frascati - RM
Tel: +39-6-944091 (switchboard)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 9440968 (direct)
E-mail:&nbsp;
&nbsp;&nbsp;&nbsp; f.iavarone@acsys.it
&nbsp;&nbsp;&nbsp; FrdndVrn@altavista.net</pre>
&nbsp;</html>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Problems with the help index
Next Topic: Re: draw text parallel to a sloping line

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

Current Time: Fri Oct 10 00:07:05 PDT 2025

Total time taken to generate the page: 0.48335 seconds