There are 2 kinds of arrays in maxima, as has been discussed.
The kind created with array, puts the name in the global arrays infolist.
The local command is used to prevent this.
The array created with make_array is assigned to a variable, and not put
in
the infolist.
Try the following sequence of commands as well.
array(a,3);
a[0]:1;
listarray(a);
f(b):=arraysetapply(b,[0],2);
f(a);
listarray(a);
Wolfgang Jenkner wrote:
> "Fabrizio Caruso" <fabrizio_caruso@hotmail.com> writes:
>
> > (1) is there a way to pass an array/matrix as a parameter by
> > reference? For example, in order to have a function change some
> > elements in an array/matrix, do I always need to copy the whole
> > array/matrix locally?
> >
> > (2) how do I declare an array local? do I need to use the "local"
> > command. Putting it in brackets after the "block" command seems not
> > to work.
>
> I'd suggest to simply set
>
> (c1) use_fast_arrays:true;
>
> (d1) true
>
> or to use `make_array' instead of `array'; this will give you lisp
> arrays (and not only symbols which refer to such arrays via their
> property list)
>
> (c2) a:make_array('any,1);
>
> (d2) #(NIL)
> (c3) foo(x):=block([a:make_array('any,1)],x[0]:true,a[0]);
>
> (d3) foo(x) := block([a : make_array('any, 1)], x : true, a )
> 0 0
> (c4) foo(a);
>
> (d4) false
> (c5) a[0];
>
> (d5) true
> (c6) ?eq(a,d2);
>
> (d6) true
>
> You might also be interested in reading the thread `RE: array and
> make_array' starting with
>
> http://www.math.utexas.edu/pipermail/maxima/2002/001926.html
>
> Wolfgang
>
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima