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.

ReplaceList[rules]

is an operator form of ReplaceList that can be applied to an expression.

Details

Examples

open allclose all

Basic Examples  (2)

Give the results of all possible replacements:

Give only the first replacement that applies:

Use ReplaceList in operator form:

Scope  (2)

Use all rules that apply:

Use only the first rule:

Find the possible values to break a sum of terms in two:

Applications  (3)

Generate all consecutive nonempty sublists:

Find all elements that appear twice:

Find all sublists flanked by the same element:

Properties & Relations  (1)

ReplaceList gives a list of results using all possible matches:

Replace gives the first, canonical match:

Wolfram Research (1996), ReplaceList, Wolfram Language function, https://reference.wolfram.com/language/ref/ReplaceList.html (updated 2018).

Text

Wolfram Research (1996), ReplaceList, Wolfram Language function, https://reference.wolfram.com/language/ref/ReplaceList.html (updated 2018).

CMS

Wolfram Language. 1996. "ReplaceList." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2018. https://reference.wolfram.com/language/ref/ReplaceList.html.

APA

Wolfram Language. (1996). ReplaceList. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ReplaceList.html

BibTeX

@misc{reference.wolfram_2024_replacelist, author="Wolfram Research", title="{ReplaceList}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/ReplaceList.html}", note=[Accessed: 17-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_replacelist, organization={Wolfram Research}, title={ReplaceList}, year={2018}, url={https://reference.wolfram.com/language/ref/ReplaceList.html}, note=[Accessed: 17-December-2024 ]}