replaces sequences in list according to the specified rule or list of rules.
does only the first n replacements.
- In SequenceReplace[list,pattrhs], patt can be an expression with head List that includes pattern constructs such as PatternSequence, Repeated (..), Blank (_) and BlankSequence (__).
- The pattern patt can also be a pattern that matches a list but does not itself have head List.
- SequenceReplace goes through a list, testing sequences that start at each successive element position. On each sequence, it tries in turn each of the transformation rules that were specified. If any of the rules apply, it replaces the sequence, then continues to go through the list, starting at the element position after the end of the sequence.
- SequenceReplace[rules][list] is equivalent to SequenceReplace[list,rules].
Examplesopen allclose all
Basic Examples (4)
Use the operator form of SequenceReplace:
Properties & Relations (6)
SubsetReplace matches the elements of the sequence in any order:
SequenceReplace matches the sequence only in the order specified:
Wolfram Research (2018), SequenceReplace, Wolfram Language function, https://reference.wolfram.com/language/ref/SequenceReplace.html.
Wolfram Language. 2018. "SequenceReplace." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SequenceReplace.html.
Wolfram Language. (2018). SequenceReplace. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SequenceReplace.html