On Fri, 12 Sep 2003 21:56:46 -0500, "Richard" <rdmerrio@amaonline.com>
wrote:
>Question 2
>Is there a way to determine if one variable is dependent on another? To
>explain what I mean, image a spreadsheet:
>
>A1=5 and A2=A1+2
>
>When I change A1, the interpreter knows that A2 is a decendent of A1 and
>automatically calculates and displays a new result for A2.
>
>Anyone have any ideas on how to emulate this behavior in poplog?
If you know A2 always depends on A1, as you describe, then this is
commonly done by defining a function, as, for example,
define A2(); A1 + 2; enddefine;
If A1 may itself be dependent on something, you could make them
both be functions:
define A1(); 5; enddefine;
define A2(); A1() + 3; enddefine;
Notice that this time the definition of A2() uses A1() not A1. If
you don't see why, then that makes a difference to what kinds of
answer you were looking for to your original question.
You can make all your "spreadsheet" variables be functions, as above,
where the formula is put into the function definition. You will run
into probems if you have circular dependencies, e.g. A1=A2+3, A2=A1-3,
which a spreadsheet would complain about.
If all the above was obvious, or doesn't answer your question, then
please try to rephrase your question so we can understand it better.
Jonathan
--
Use jlc at address, not spam.
Riemann's Hypothesis: It is known that the first 1.5 billion roots
are of the conjectured form. However, many phenomena of this type
are known in which trends for small numbers are misleading.
|