#6195: [with patch, needs review] in symbolic Expression.match() return a
dictionary with matched values of wildcards
----------------------------+-----------------------------------------------
Reporter: burcin | Owner: burcin
Type: defect | Status: assigned
Priority: major | Milestone: sage-4.1
Component: symbolics | Keywords:
Reviewer: Nick Alexander | Author: Burcin Erocal
Merged: |
----------------------------+-----------------------------------------------
Changes (by burcin):
* status: new => assigned
Comment:
Replying to [comment:1 ncalexan]:
> Why does the first match but the second not?
{{{
sage: ((x+y)).match(w0+w1)
{$1: x, $0: y}
sage: ((x+x)).match(w0+w1)
}}}
{{{
sage: t = (x+x); t
2*x
sage: t.operator()
<built-in function mul>
}}}
You're looking for an add object, matching doesn't work algebraically in
this case. We could start a "pitfalls of pattern matching in symbolics"
wiki page to document these.
> Can you explain the difference in these behaviours?
{{{
sage: ((x+y)^a).match((x+y)^a)
{}
sage: print ((x+y)^a).match((x+y)^b)
None
}}}
The first example doesn't have any wildcards. It is a match, so it returns
a dictionary, but without any keys. There is no match in the second
example, so we return None. As I say in the description, I'm open to
suggestions to improve the interface.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6195#comment:3>
Sage <http://sagemath.org/>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---