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 #19064 is a reply to message #19024] Tue, 22 February 2000 00:00 Go to previous messageGo to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
Craig Markwardt wrote:
>
> Pavel Romashkin <pavel@netsrv1.cmdl.noaa.gov> writes:
>
>>> What can you say of a language that is purely array oriented, but
>>> cannot comprehend the existence of an empty array?
>>
>> Agreeing with D.F., I so far had no use for an empty array. I
>> understand it is not flexible, but I usually work on data other than
>> nothing.
>
> Forgive him, he knows not what he says.
>
> Empty arrays would be invaluable in both indexing (such as with WHERE)
> and array concatenation. By invaluable, I mean that it would remove a
> lot of the special casing. Consider these examples:
>
> ARRAY INDEXING - indexing with where()
> *With* an empty array:
> wh = where(array GT thresh, /EMPTY)
> array(wh) = 0 ;; indexing with empty array has no effect
> *Without* an empty array
> wh = where(array GT thresh, count)
> if count GT 0 then array(wh) = 0
>
> ARRAY CONCATENATION - growing an array
> *With* an empty array:
> l = empty_array()
> for i = 0, 100 do if expression(values) then l = [l, values]
> *Without* an empty array:
> for i = 0, 100 do $
> if expression then $
> if n_elements(l) EQ 0 then l = [values] else l = [l, values]
>
> As you can see, the "with" code is more simple and easy to read. The
> "without" (which represents the status quo) has special cases which
> ruin the flow of thought. For a vectorized language, this is a
> painful burden to bear sometimes. If you don't believe me, try doing
> the following (apparently simple) problem:
>
> * 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

JD


--
J.D. Smith |*| WORK: (607) 255-5842
Cornell University Dept. of Astronomy |*| (607) 255-6263
304 Space Sciences Bldg. |*| FAX: (607) 255-5875
Ithaca, NY 14853 |*|
[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:58:00 PDT 2025

Total time taken to generate the page: 0.00542 seconds