help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: conditional expr operator in Octave?


From: Jaroslav Hajek
Subject: Re: conditional expr operator in Octave?
Date: Thu, 30 Jul 2009 21:02:35 +0200

On Thu, Jul 30, 2009 at 8:49 PM, John W. Eaton<address@hidden> wrote:
> On 30-Jul-2009, Jaroslav Hajek wrote:
>
> | OK, I'm dropping it; instead, I implemented the "merge" function aka
> | Fortran 90 (which I needed for some time) and slightly extended the
> | scalar mask case to allow arbitrary (even non-array) values.
> | http://hg.savannah.gnu.org/hgweb/octave/rev/833109a9f37f
> |
> | merge (mask, tval, fval)
> | can now be used instead of mask ? tval : fval (except that it does not
> | short-circuit).
>
> The name "merge" doesn't seem very intuitive to me.  What about using
> "ifelse" instead?
>

I borrowed the name from Fortran 90. It makes sense if you think of
the array usage: it merges the two arrays, tval and fval, according to
mask. I just realized that this function can actually be used instead
of the conditional operator.
I have no problem calling it ifelse instead, but merge also makes good
sense. OTOH, "ifelse" is probably less likely to clash with anything
else ("merge" can suit many functions), so perhaps it is a better
name.

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]