array functions



"Stavros Macrakis" <stavros.macrakis@verizon.net> writes:

> Wolfgang says:
> 
> > On the other hand, this seems to imply that function arrays can't be
> > used to manipulate global bindings. Hmm...
> 
> No, that's not true.  Your example works the way it does because of the
> double evaluation.
> 
> The following shows what is going on:
> 
> (C1) f[i](x):=[argvals:cons([i,x],argvals),
>               '(qargvals:cons([i,x],qargvals))]$
> 
> /* The first part is evaluated when f[i] is calculated;
>    the second (quoted) part only when f[i] is applied to x. */
> 
> (C2) (argvals:[], qargvals: [])$
[...]

Very nice example.  I was aware of the double evaluation issue
(because of CONSTLAM, where the first evaluation occurs) but I was
thinking only of the usual unadorned type of assignment like for your
argvals above (and your example shows that argvals is changed only
when a new f[i] is calculated).

By the way, I wrote

> So, apparently, the forms which make up the function definition are
> MEVALed in Maxima's global environment (which has the side-effect of
> printing x) and the results are put together to form the cached
> function definition, at least in simple cases like this one.

but, of course, `global environment' is nonsense, I should have said
`suitable environment' ;-)

Wolfgang