Testing Mathematica Expressions?
- To: mathgroup at smc.vnet.net
- Subject: [mg106593] Testing Mathematica Expressions?
- From: AES <siegman at stanford.edu>
- Date: Sun, 17 Jan 2010 07:13:13 -0500 (EST)
- Organization: Stanford University
Let a sequence of characters that one might type into a Mathematica
Input cell and then evaluate (i.e., by hitting the Enter key) be called
an inputValue.
Suppose one would like to systematically explore or test and display (in
a printed tabular form) how Mathematica would proces, execute and
display (in an Output cell) a large number of such inputValues, and also
the same inputValues when followed by one or more predefined rules.
In other words, something like the following:
ruleOne = {lhs->rhs};
InputValuelist = {"expr1", "expr2", . . . };
(* Each exprx is an inputValue as defined above *)
Table[{
{inputValue},
{Fullform[ToExpression[inputValue]]},
{ToExpression[inputValue]},
{Fullform[ToExpression[inputValue] /. ruleOne]},
{ToExpression[inputValue] /. ruleOne}},
{inputValue, inputValueList}]
What would be a reliable way to accomplish this objectves?
NOTES & QUESTIONS:
1) Output should probably be formatted in Column form, since individual
items may be lengthy.
2) Better to do this using Table? Or Module? or Do loop?
3) Can you make this work using inputValues that are compound
expressions? (i.e., there are some one or more semicolons inside expr-n)
4) What Clear[-]'s need to be inserted in this structure, and where, so
earlier inputValues won't affect behavior of later ones?
5) Is ToExpression["exprx"] /. ruleOne really exactly the same thing
(or, will it produce exactly the same results) as exprx /. ruleOne ?
6) Other gotchas?