# Search Results

Results tagged with Search options user 142
34 results

Questions about how Mathematica evaluates expressions, tracing evaluation (Trace*), handling expressions in unevaluated form (Hold*, Unevaluated), nonstandard evaluation, etc.

You can watch the evaluations of a function using On: SetAttributes[zot, HoldFirst] zot[x_, y_] := {x, y} On[zot] In[11]:= zot[1+1, 2+2] During evaluation of In[11]:= zot::trace:zot[1+1,2+2 … ] --> zot[1+1,4]. During evaluation of In[11]:=zot::trace: zot[1+1,4] --> {1+1,4}. Out[11]= {2,4} Here we can see the original unevaluated arguments to zot and also the partially evaluated arguments …
answered Feb 28 '14 by WReach
is given the HoldAll attribute to delay the evaluation of the arguments until after we have had a chance to process them. It wraps the supplied sequence of symbols in Hold and then uses Replace to …
answered Apr 5 '14 by WReach
: Iteration limit of 4096 exceeded. >> *) To guard against this possibility, we make sure that the last definition only takes effect if the evaluation of its argument actually resulted in a change … themselves HoldAll because Block will temporarily disable that attribute as well, leading to evaluation leaks. It would also be unsuitable if the application will not tolerate the partial evaluation of expressions such as we see in the last example above. …
answered Jan 31 '15 by WReach
h[e1,e2,...]. The evaluation sequence is described in more detail in Chapter 7 of Power Programming with Mathematica by David B. Wagner. It is freely available to StackExchangers via (16485). When … they self-evaluate. Such symbols are said to be "inert". In the present case, f is inert. As a result, when evaluation gets down to the eleventh step the down-value of f is used to produce the …
answered Oct 11 '16 by WReach
We can define a new "variable container" that can be used to assign the same value to multiple variables: ClearAll[vars] SetAttributes[vars, HoldAll] vars /: s:(_vars = _) := CompoundExpression @@ Th …
answered Jan 21 '12 by WReach
Evaluation stops when there is no definition in place whose pattern matches the expression being evaluated. Conversely, evaluation will continue as long as there is a matching definition. Thus, if … I have this definition: zot[x_] := zot[x] and I evaluate zot[1], the evaluation will never terminate even though the expression never changes. (Well, in principle it will never terminate but …
answered Mar 17 '11 by WReach
prints the tracing information as execution proceeds instead of returning that information in the final evaluation result. Thus, TracePrint meets the stated requirement. However... The output of … the draw, it will crash. Also, the front-end is slow to respond to Abort Evaluation requests when large quantities of output are present. TraceScan TraceScan is an alternative to TracePrint that …
answered Jan 17 '15 by WReach
We can use some of Mathematica's built-in tracing facilities to help us answer this question. Let's start by ensuring that the symbols we are about to use carry no extraneous definitions: ClearAll[f …
answered Jan 28 '15 by WReach
. Responding to the Updated Question If we wish to update the original variables, we need to prevent the evaluation of the individual variables. For example: Scan[Function[Null, PrependTo[#, {"A", "B … programs the chance for so-called "evaluation leaks" to spring up grows quickly. All of the built-in destructive operators (like PrependTo, Set, SetDelayed etc) require held arguments. In other …
answered Mar 8 '17 by WReach
I agree with @Ymareth that the simplest thing would be to have the calling notebook take explicit measures to communicate the context to the target notebook. However, if for some reason it is undesir …
answered Dec 1 '14 by WReach
Short Version The behaviour we see is by design. It is due to the fact that we are using the special head Evaluate to force early evaluation of the second argument of CompoundExpression -- an … wrap the second expression within Evaluate, it is evaluated before the compound expression itself is evaluated: Print["one"]; Evaluate[Print["two"]] (* two one *) After that early evaluation and …