Lists and arrays with the same name



To extract an element of a Maxima list, either use inpart or use the local declaration; example

 (%i1) a[1] : x$

 (%i2) f(k) := block([a : [5,6,7]], a[k])$

 (%i6) g(k) := block([a : [5,6,7]], (local(a), a[k]))$

 (%i8) h(k) := block([a : [5,6,7]], inpart(a,k))$

 (%i10) [f(1), g(1), h(1)];
 (%o10) [x,5,5]

Of these two methods, inpart is the most foolproof, I think.

--Barton

-----maxima-bounces at math.utexas.edu wrote: -----


>??Probably?you?should?stop?your?practice?of?using?the?same?name?for?two?
>or?more?different?things.
>Maxima?is?quite?capable?of?using?the?same?name?for?more?than?one?thing.
>You?might?also?confuse?yourself?further?defining?a?function?b?as?well?as?
>using?b?as?a?local
>variable?in?a?block.
>
>It?may?not?be?easy?to?explain,?but?it?is?usually?easy?to?avoid?such?
>overloading.
>
>RJF
>
>
>
>_______________________________________________
>Maxima?mailing?list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima