Subject: how to pass the name of a variable as argument?
From: Oliver Kullmann
Date: Fri, 2 May 2008 01:14:23 +0100
Hi,
I often have to compute functions f which
compute, say, a set of values f(x), and where
the computation might take a very long time
--- but we don't know how long it will take.
Furthermore we assume that the elements of
the set f(x) are computed one after another.
Now the problem is that apparently it is
not possible to just stop Maxima in a computation
and to inspect the values of local variables of
a function. So there doesn't seem to be a simple
direct solution to the problem that after a day
or so we have enough, we want to stop the
computation of f(x), but we want to get the partial
results (the elements of that set yet computed)
nevertheless.
Since global variables should be avoided, a good
solution would be to pass the name of a variable
to f, so that then we could use
partial_result : {};
f(name of "partial result");
inspect partial_result;
Obviously
f(x) := x : adjoin(1,x);
doesn't work (here the task is, given a set x,
add element 1 to it).
I experimented a bit with "nouns" etc., but
I didn't succeed. Could somebody show me for this
example how to make it work:
a : {5,6};
f(some function of "a");
assert(a = {1,5,6});
Thanks for your attention!
Oliver