I want to selectively remove a hashed array inside a
block definition of a function.
The following is a toy model of what happens, in which
I am not successful in removing a hashed array from the
list arrays, nor in getting Maxima to forget the assignment
of the components, whether I use remarray or kill inside the
block.
--------------------------------
(%i1) display2d:false$
/* define two hashed arrays */
(%i2) [p1[0],p1[1],p2[0],p2[1]] : [E,p,M,q]$
(%i3) arrays;
(%o3) [p1,p2]
(%i4) listarray(p1);
(%o4) [E,p]
(%i5) listarray(p2);
(%o5) [M,q]
/* method 1: use of remarray inside block :
crashes with some lisp error?? */
(%i6) remha1( [v] ) := block ([jj],
for jj thru length (v) do remarray (v[jj]))$
(%i7) remha1 (p1);
Maxima encountered a Lisp error:
Error in PROGN [or a callee]: Caught fatal error [memory may be damaged]
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
/* method 2 : add some window dressing inside block but still
use remarray: no crash but no removal. */
(%i8) remha2( [v] ) := block ([jj,pp],
display(v),
for jj thru length (v) do (
pp : v[jj],
display(jj,pp),
remarray ( pp) ) )$
(%i9) remha2 (p1);
v = [p1]
jj = 1
pp = p1
(%o9) done
(%i10) arrays;
(%o10) [p1,p2]
(%i11) listarray(p1);
(%o11) [E,p]
/* method 3 : use kill inside block : no crash but no removal */
(%i12) remha3( [v] ) := block ([jj,pp],
display(v),
for jj thru length (v) do (
pp : v[jj],
display(jj,pp),
kill ( pp) ) )$
(%i13) remha3(p1);
v = [p1]
jj = 1
pp = p1
(%o13) done
(%i14) arrays;
(%o14) [p1,p2]
(%i15) listarray(p1);
(%o15) [E,p]
/* method 4, which I don't want to use for programming reasons:
interactive remarray: removes ok */
(%i16) remarray(p1);
(%o16) [p1]
(%i17) arrays;
(%o17) [p2]
(%i18) p1[0];
(%o18) p1[0]
/* method 5, which again I don't want to use: use interactive kill:
removes array def */
(%i19) kill(p2);
(%o19) done
(%i20) arrays;
(%o20) []
(%i21) p2[0];
(%o21) p2[0]
-------------------------------
Any suggestions??
I am using windows xp, maxima 5.19.2
Ted Woollett