replaces sublists in list according to the specified rule or list of rules.
does only the first n replacements.
- In SubsetReplace[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.
- Sublists matching patt can appear in list in any order.
- SubsetReplace applies transformation rules in the order in which they appear in rules. Elements of a matching sublist are removed from list and the corresponding rhs is inserted at the position of the element of the sublist that was matched first. Subsequent transformations are applied to elements that have not been transformed yet.
- SubsetReplace[rules][list] is equivalent to SubsetReplace[list,rules].
Examplesopen allclose all
Introduced in 2020