On Jan 23, 8:09 am, dh <d... at metrohm.com> wrote:
> Hi Bert,
>
> nothing exotic here. The return value is a function that consits of a
>
> [snip]
Well, there is one thing which may be mildly exotic
for those not familiar with it: the function is
returned is wrapped by a closure, which is why it
is able to retain the value of the counter variable.
(The closure is not air-tight, though:
In[1]:= f[a_] := Module[{aa = a, ff},
ff[i_] := (aa += i; aa);
ff
];
In[2]:= q = f[0]
Out[2]= ff$14
In[3]:= q[2]
Out[3]= 2
In[4]:= aa$14 = 0;
In[5]:= q[3]
Out[5]= 3
Can one get a really closed closure?)
-- m