ReplaceList

ReplaceList[expr,rules]

attempts to transform the entire expression expr by applying a rule or list of rules in all possible ways, and returns a list of the results obtained.

ReplaceList[expr,rules,n]

gives a list of at most n results.

Details

  • When no transformation is possible, ReplaceList returns {}.

Examples

open allclose all

Basic Examples  (1)

Give the results of all possible replacements:

In[1]:=
Click for copyable input
Out[1]=

Give only the first replacement that applies:

In[2]:=
Click for copyable input
Out[2]=

Scope  (2)

Applications  (3)

Properties & Relations  (1)

See Also

Replace  ReplaceAll  StringReplaceList  Cases  Trace  Position  Split

Tutorials

Introduced in 1996
(3.0)