new() is the constructor for Math::Symbolic::Custom::Pattern objects.
It takes a Math::Symbolic tree as first argument which will be transformed
into a pattern. See the match() method documentation.
After the Math::Symbolic tree, a list of key/value pairs can be passed in as options for the pattern construction.
The only currently supported option is commutation indicating whether or not the pattern should match sums and products commutatively. Please note that this does not match recursively and does not recognize associativity: The commutative pattern of (a + b) + c matches the expression (b + a) + c and c + (b + a), but <B>notB> a + (b + c)! This means that if the tree to match is built from a string such as a + b + c, then it is not defined whether (a + b) + c matches that expression. It does so if the internal tree representation happens to be (a + b) + c and it doesnt if it happens to be a + (b + c). This may be fixed at a later point.
This method takes a Math::Symbolic tree as first argument. It throws a
fatal error if this is not the case.
As a matter of fact, if you need to know what subtrees were matched by the various VAR_foo, TREE_bar, and CONST_baz identifiers, you can find out by inspecting the return value of a successful match. It will be a reference to a hash containing three key/value pairs with the keys trees, vars, and constants. Each of these will again point to a hash. These hashes contain the names of the matched subtrees. For example, if your pattern is TREE_x + TREE_x and it matches foo*bar + foo*bar, then the return value will be:
Except that foo*bar will actually be the corresponding Math::Symbolic tree and not a string. Please note that the subtrees are real subtrees. Modifying them will result in a modified original tree as well.
|to_string||Returns a string representation of the pattern.|
New versions of this module can be found on http://steffen-mueller.net or CPAN.
Math::Symbolic::Custom::Pattern::Export implements the is_of_form() and to_pattern() methods.
Steffen MXller, <firstname.lastname@example.org>
Copyright (C) 2005, 2006, 2008, 2009, 2013 by Steffen Mueller
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
|perl v5.20.3||MATH::SYMBOLIC::CUSTOM::PATTERN (3)||2013-05-26|