Reputation: 611
Suppose the following example
g(x):=block([],
x:x+1
);
xx:1$;
g(xx)$;
xx;
This outputs 1
. How can I have it output 2
?
Edit: I searched for "maxima" combined with "pass by reference" and the results don't seem to suggest that "pass by reference" is really a thing defined in Maxima but if you know what I mean, that's what I want.
Upvotes: 2
Views: 47
Reputation: 11
I think your trouble is simply that you have both % and ; in the xx assignment line.
Here's what works for me:
g(x):=block([],
x:x+1
);
xx:1;
g(xx);
Upvotes: 1
Reputation: 5768
You can use a macro (an utility that generates maxima code).
(%i1) g(x)::=buildq([x], x : x + 1) $
(%i2) a: 1 $
(%i3) g(a) $
(%i4) a ;
(%o4) 2
Upvotes: 1