repeatedly performs replacements until expr no longer changes.
Details and Options
- expr//.rules effectively applies /. repeatedly, until the results it gets no longer change.
- It performs one complete pass over the expression using /., then carries out the next pass.
- You should be very careful to avoid infinite loops when you use the //. operator. The command x//.x->x+1 will, for example, lead to an infinite loop.
- ReplaceRepeated takes the option MaxIterations, which specifies the maximum number of times it will try to apply the rules you give. The default setting is MaxIterations->65536. With MaxIterations->Infinity there is no limit.
- ReplaceRepeated[rules][expr] is equivalent to ReplaceRepeated[expr,rules].
Examplesopen allclose all
Basic Examples (3)
ReplaceRepeated works inside held expressions:
Properties & Relations (5)
ReplaceRepeated scans multiple times from the top of an expression:
ReplaceAll replaces the largest subexpressions it can and then stops:
Wolfram Research (1988), ReplaceRepeated, Wolfram Language function, https://reference.wolfram.com/language/ref/ReplaceRepeated.html (updated 2018).
Wolfram Language. 1988. "ReplaceRepeated." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2018. https://reference.wolfram.com/language/ref/ReplaceRepeated.html.
Wolfram Language. (1988). ReplaceRepeated. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ReplaceRepeated.html