[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: Re: Numerical Differentiation and Integration of Array Data
From: |
Martin Helm |
Subject: |
Fwd: Re: Numerical Differentiation and Integration of Array Data |
Date: |
Wed, 07 Dec 2011 23:30:29 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
Am 07.12.2011 23:11, schrieb syberraith:
> It was my impression from the first few lines of the Octave manual entry for
> anonymous functions that they would have access to variables defined in the
> next higher scope:
>
They have! What you create by using free variables in an anonymous
function which are defined in the next higher lexical scope is strictly
speaking a closure.
I use that often.
octave:1> a =2; b=3;
octave:2> f = @(x) a*x+b;
octave:3> f(3)
ans = 9
octave:4> a = 10;
octave:5> f(3)
ans = 9
changing the free variable later has no effect to the closure, the closed
over variables still have the value within the anonymous function they
originally had at the time of definition.
- Re: Numerical Differentiation and Integration of Array Data, (continued)
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/07
- Message not available
- Re: Numerical Differentiation and Integration of Array Data, Carlo de Falco, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/03
Fwd: Re: Numerical Differentiation and Integration of Array Data,
Martin Helm <=