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 #19070 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
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.

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: Thu Oct 09 18:59:42 PDT 2025

Total time taken to generate the page: 1.36557 seconds