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

Home » Public Forums » archive » Re: list manipulation
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: list manipulation [message #78799] Sun, 18 December 2011 10:46
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Dec 18, 10:29 am, greg.a...@googlemail.com wrote:
> I tried like this, which works:
>
> IDL> b=list(a[0],a[1],a[2],/extract)
> IDL> print,b
>        1
>        2
>        3
>        2
>        3
>        4
>        5
>
> ..but in real life, 'a' contains hundreds of short arrays, so that line's impractical. The following, which I could easily make - and would expect to be equivalent - doesn't work:
>
> IDL> b=list(a[[0,1,2]],/extract)
> IDL> print,b
>        1       2       3
>        2
>        3       4       5
>
> Am I missing something obvious?
>
> cheers,
> Greg

Now it is something that sound working!!
Cheers,
Dave
Re: list manipulation [message #78800 is a reply to message #78799] Sun, 18 December 2011 10:29 Go to previous message
greg.addr is currently offline  greg.addr
Messages: 160
Registered: May 2007
Senior Member
I tried like this, which works:

IDL> b=list(a[0],a[1],a[2],/extract)
IDL> print,b
1
2
3
2
3
4
5

..but in real life, 'a' contains hundreds of short arrays, so that line's impractical. The following, which I could easily make - and would expect to be equivalent - doesn't work:

IDL> b=list(a[[0,1,2]],/extract)
IDL> print,b
1 2 3
2
3 4 5

Am I missing something obvious?

cheers,
Greg
Re: list manipulation [message #78801 is a reply to message #78800] Sun, 18 December 2011 10:22 Go to previous message
greg.addr is currently offline  greg.addr
Messages: 160
Registered: May 2007
Senior Member
Thanks for that, Vincent (and the pedagogical device wasn't wasted on me!) This extract keyword is what I need, I think - except that it doesn't work the way I hoped in my case:

IDL> a=list()
IDL> a.add,[1,2,3]
IDL> a.add,2
IDL> a.add,[3,4,5]
IDL> b=list(a,/extract)
IDL> print,b
1 2 3
2
3 4 5

I thought - ok, it thinks that's just one element, so what if I add another:

IDL> b=list(a,[1],/extract)
IDL> print,b
1 2 3
2
3 4 5
1

Still no. How would you get [1,2,3,2,3,4,5] from a?

cheers,
Greg
Re: list manipulation [message #78802 is a reply to message #78801] Sun, 18 December 2011 06:59 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
DavePoreh writes:

>
> On Dec 18, 4:33 am, Vincent Sarago <vincent.sar...@orange.fr> wrote:
>> Hello Greg,
>>
>> normally with the List object you have to use the 'FindValue' method :
>>
>> IDL> A = indgen(10)
>> IDL> B = indgen(10) + 10
>> IDL> C = indgen(3) + 50
>> IDL> lis = list(a,b,c, /extract)
>> IDL> d = l.FindValue(10)
>> IDL> print, d
>>           10
>>
>> vincent
>
> that is not working for me!!!

A common pedagogical device, used sometimes on exams,
and extensively in newsgroups such as this, is to
throw a little misdirection into the answer by
slightly mistyping one of the otherwise clear
directions. This not only gives the end user
a sense of accomplishment in figuring something out
for him or herself, but allows the answer provider
to imagine that he isn't doing ALL the damn work!

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: list manipulation [message #78803 is a reply to message #78802] Sun, 18 December 2011 04:43 Go to previous message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Dec 18, 4:33 am, Vincent Sarago <vincent.sar...@orange.fr> wrote:
> Hello Greg,
>
> normally with the List object you have to use the 'FindValue' method :
>
> IDL> A = indgen(10)
> IDL> B = indgen(10) + 10
> IDL> C = indgen(3) + 50
> IDL> lis = list(a,b,c, /extract)
> IDL> d = l.FindValue(10)
> IDL> print, d
>           10
>
> vincent

that is not working for me!!!
Dave
Re: list manipulation [message #78804 is a reply to message #78803] Sun, 18 December 2011 04:33 Go to previous message
Vincent Sarago is currently offline  Vincent Sarago
Messages: 34
Registered: September 2011
Member
Hello Greg,


normally with the List object you have to use the 'FindValue' method :

IDL> A = indgen(10)
IDL> B = indgen(10) + 10
IDL> C = indgen(3) + 50
IDL> lis = list(a,b,c, /extract)
IDL> d = l.FindValue(10)
IDL> print, d
10


vincent
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: list manipulation
Next Topic: Extending or resizing array in IDL

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

Current Time: Wed Oct 08 15:49:35 PDT 2025

Total time taken to generate the page: 0.00615 seconds