HOW TO FIND THE VARIABLES IN 'EQ'
by Joe Horn
Brad Harvell (beef@Primenet.Com) writes:
> there is an entry, I forget the name, but its something like EQID{}
> or somthing... that takes an eq and outputs a list of all vars used
> in the eq. you could see which vars in that list do not exist.
FINDVAR is an unsupported entry point, but it has remained at
#353ABh in all versions of the HP48 so far. It's used by the Solver
menu builder, and is very fast. Its stack syntax is:
'equation' #353ABh SYSEVAL --> { list of vars }
Some notes about FINDVAR:
(1) It's recursive, so if it finds a var in the algebraic object which
itself is the name of an algebraic, it'll add *that* algebraic's vars
to the list, and not the "parent" algebraic's name. Example: If 'S'
contains 'Q+R', then 'S+T' FINDVAR will *not* yield { S T }, but
{ Q R T } instead. This is why the Solver menu recurses into
variables.
(2) FINDVAR weeds out any variables which contain a program, a
symbolic (see #1 above), or a directory. FINDVAR finds only those
variables which either do not yet exist, or which contain object types
other than these. This is why the Solver menu doesn't let you destroy
programs, algebraics, or directories.
If #2 above is unacceptable, you can use this alternative for FINDVAR:
{} DUP ROT #353C9h SYSEVAL
This acts like FINDVAR, except it also places on level 2 a list of the
weeded-out names of programs, symbolics, and/or directories. This is
also an unsupported entry point which has not moved in any version of
the HP48 so far.
On a G/GX, you can remove nonexistent vars from a list this way:
1 << DUP VTYPE -1 SAME { DROP } IFT >> DOSUBS
If you want just the nonexistent vars instead, use this:
1 << DUP VTYPE 1 + { DROP } IFT >> DOSUBS
-Joe Horn-