octave-maintainers
[Top][All Lists]
Advanced

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

Re: @(x) plus(x,++j)


From: Ben Abbott
Subject: Re: @(x) plus(x,++j)
Date: Fri, 23 May 2014 11:40:48 -0400

On May 23, 2014, at 7:43 AM, Muhali <address@hidden> wrote:

> right. I missed the argument for f. So what I meant was
> 
> feval(f, 0)
> 
> and, resp.,
> 
> feval(@(x) plus(x,++j), 0)

I'll use a simpler version of your function.

        j = 0
        f = @() ++j ;

f()
ans =  1
 f()
ans =  2
 f()
ans =  3
 f()
ans =  4

However, in the global space the value of "j" has not changed. 

j
j = 0

"j" is only changing in the variable space local to the function "f"

Each of the statements like below are independent instances of identical 
functions.

        feval(@() ++j, 0)

Meaning that there the initial value for "j" is inherited from the command line 
variable space, but each instance of the function modifies it in its local 
space.

Ben




reply via email to

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