Re: Unevaluated functions
- To: mathgroup at smc.vnet.net
- Subject: [mg109343] Re: Unevaluated functions
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Thu, 22 Apr 2010 06:43:51 -0400 (EDT)
- References: <hqou0u$9g5$1@smc.vnet.net>
Hi, > In Mathematica when a function returns unevaluated the "return value" > is the name of the function with arguments. you should understand that a function definition is nothing but a replacement rule in Mathematica. Evaluation means that all stored replacement rules are tried on a given expression until it doesn't change anymore. The result that you see is not a return value but the original expression because no pattern will match and no "function call is executed". > How do we control such output? Can we suppress it? How do we change > the usual string for something like "N/A"? what you see is no string but an expression. There are plenty ways to change the behavior of Mathematica in this respect, but they differ a lot in what they really do. To give you a useful answer you would need to explain a little better what you try to achieve and why you don't want to "see" the unevaluated expressions. Here are two possibilities which behave very different: 1) for a given function, add a rule that replaces "everything else" with the desired "unevaluated" result: ClearAll[f]; f[x_]:=x^2; f[___]:="N/A"; test: f[a] f[a,b] f[a,b]//Head 2) define a format rule. Note that this will only change the appearance in the notebook, not the actual "return value": ClearAll[g]; Format[g[___]]:="N/A"; g[x_]:=x^2; test: g[a] g[a,b] g[a,b]//Head hth, albert