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

Home » Public Forums » archive » idl2matlab translate-o-matic
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: idl2matlab translate-o-matic [message #19061 is a reply to message #19024] Tue, 22 February 2000 00:00 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"J.D. Smith" <jdsmith@astro.cornell.edu> writes:

> Craig Markwardt wrote:
>> * given two arrays, A and B: concatenate all but the last two
>> elements of A, with B. Don't try [A(0:n-3),B], or you will be in a
>> world of hurt.
>>
>
> I wouldn't say a *world* or hurt. Maybe a minor planetesimal of hurt:
>
> C=n_elements(A)>2?[A[0:n_elements(A)-3],B]:B

Okay, my creative juices weren't flowing yet. Consider that a warm-up
problem.

How about this one:

* Given two 1-d arrays, A and B: insert B into any arbitrary position
I in A.

I was hoping that it would be as easy as this, a = [a(0:i-1),b,a(i:*)],
but then the special cases get start to be overwhelming (for example when i
equals 0 or n_elements(a)). My point was that indexing with an empty
range should produce an empty list.

Instead you get this,

if i EQ 0 then begin
a = [b, a]
endif else if i EQ n_elements(a)-1 then begin
a = [a, b]
endif else begin
a = [a(0:i-1),b,a(i:*)]
endelse

And if A or B are allowed to be empty or undefined at the start then
things get even *more* hurtful (perhaps even approaching a worldful).

These are all normal set-like things I'd like to do. Thankfully there
are useful convenience routines like the Astronomy Library's
STORE_ARRAY, but somehow I think these issues could be better
addressed by making the language itself complete.

Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: running different IDL versions simultaneously
Next Topic: voxel_proj and seg fault

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

Current Time: Wed Oct 08 19:25:42 PDT 2025

Total time taken to generate the page: 0.16159 seconds