def match(self,search): for expr in core.commutative_permutations(search): res = core.match(self,expr) if res: return ReplacementMap(core.match(self,expr),self.S) return None
def commutative_permutations(expr): for expr in core.commutative_permutations(expr): yield S(expr)