help-octave
[Top][All Lists]
Advanced

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

Re: Behavior of octave and ans


From: François Poulain
Subject: Re: Behavior of octave and ans
Date: Mon, 7 Jul 2014 16:33:15 +0200

Hi,

Le Mon, 7 Jul 2014 10:07:51 -0400,
Mike Miller <address@hidden> a écrit :

> Yes, this is the correct behavior. The special ans variable is only
> updated when there is no lvalue being assigned to in the outermost
> expression.

Ok.

> Since you are using eval, you could rewrite the user-input expression
> to assign it to a particular named variable of your own choosing, and
> get the result from its value. So for example
> 
>   texmacs_result = a=1
>   texmacs_result = b=a=1
>   texmacs_result = a+1
> 
> all update the variable texmacs_result. This should be equivalent to
> what you were expecting the ans variable to be.
> 
> Does that do what you need?

Yes, but it may change the evaluation behaviour. As an example,
texmacs_result = plot(1) behave differently from plot(1), and
polyfit (1, 1, 1) behave differently from texmacs_result=
polyfit (1, 1, 1).

So, it is uneasy to guess when we should and when we should not add an
assignation.

François

-- 
François Poulain <address@hidden>



reply via email to

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