Mathematica Asked by asd1dsa on April 11, 2021
In the documentation tutorial/Evaluation
it’s said that:
Every time the expression changes, the Wolfram Language effectively starts the evaluation sequence over again.
And in tutorial/EvaluationOfExpressions
:
The general principle that the Wolfram Language follows in evaluating expressions is to go on applying transformation rules until the expressions no longer change.
A similar statement appears for ReplaceRepeated
, too:
expr//.rules
repeatedly performs replacements untilexpr
no longer changes.
But there’re differences:
ReplaceRepeated
, it’s replaced just once:
ReplaceRepeated[h[], h@x___ -> (Print@1;h@x)]
(* h[] *)
Blank
pattern, infinite evaluation occurs:
g[x_]:=g[x]
Block[{$IterationLimit = 20},
g[y]
]
(* Message[$IterationLimit::itlim, 20] *)
(* Hold[g[y]] *)
Blank
and Repeated
, it’s rewrited only once.
f[x]:=f[x]
Trace@f[x]
(* {f[x], f[x]} *)
What is the exact description of the condition for the termination of infinite rewriting?
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP