sym_match(e, pattern) matches an expression against a pattern containing
Wild() symbols and returns a named list of bindings, or NULL. Sums and
products match up to commutativity, and a wild may take the identity.
sym_replace(e, pattern, value) rewrites every subexpression that matches,
bottom up; value is an expression in the same wild symbols or a function
of the named bindings. When pattern is an R predicate, sym_replace()
replaces every node it accepts by value (an expression, or an R function
of the node), as SymPy's replace() with a callable query.
Arguments
- e
An expression.
- pattern
A pattern containing wild symbols, a function class made by
Function(), which matches every application of that function, or forsym_replace()an R predicate of a node.- old
Use the old matching that skips the operation count check.
- value
The replacement; for a function class pattern, another function class or an R function called with the application's arguments.
- exact
sym_replace()replaces only when no wild matched zero; by default when the pattern has more than one wild.