octave-maintainers
[Top][All Lists]
Advanced

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

Re: evaluation order in matlab/octave


From: John W. Eaton
Subject: Re: evaluation order in matlab/octave
Date: Sat, 27 Sep 2008 14:14:02 -0400

On 27-Sep-2008, Levente Torok wrote:

| On Saturday 27 September 2008, you wrote:
| > On Sat, Sep 27, 2008 at 5:59 PM, Levente Torok <address@hidden> wrote:
| > > Hi!
| > >
| > > The following expression runs differently on octave than on matlab:
| > >
| > > function z = f( par )
| > >    if ( nargin==0 | isempty(par) )
| > >        z=3;
| > >    end
| > > end
| > >
| > > Calling
| > >        f;
| > > results in differences.
| > >
| > > In matlab if the first part of the if statment is true, the second term 
is not evaluated hence it
| > > runs fine.
| > > In octave it raieses and error that par is not defined.
| > > Is there a way to overcome this or it would cause too much work.
| > >
| > 
| > You can simply use || and && in Octave.
| 
| Thanks but I was about to use a code written to matlab.
| This is it.

Matlab has had the || and && operators for some years now.  Please
look at the Octave FAQ to see why we think the way that Matlab does
short-circuiting with | and & is a bad feature that should not be
copied.

jwe


reply via email to

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