本文整理汇总了Python中mathics.core.pattern.Pattern类的典型用法代码示例。如果您正苦于以下问题:Python Pattern类的具体用法?Python Pattern怎么用?Python Pattern使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pattern类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
def init(self, expr):
super(Except, self).init(expr)
self.c = Pattern.create(expr.leaves[0])
if len(expr.leaves) == 2:
self.p = Pattern.create(expr.leaves[1])
else:
self.p = Pattern.create(Expression('Blank'))
示例2: match
def match(expr, form, evaluation):
class StopGenerator_MatchQ(StopGenerator):
pass
form = Pattern.create(form)
def yield_func(vars, rest):
raise StopGenerator_MatchQ(Symbol("True"))
try:
form.match(yield_func, expr, {}, evaluation)
except StopGenerator_MatchQ, exc:
return True
示例3: apply
def apply(self, expr, form, evaluation):
'MatchQ[expr_, form_]'
class StopGenerator_MatchQ(StopGenerator):
pass
form = Pattern.create(form)
#for vars, rest in form.match(expr, {}, evaluation):
def yield_func(vars, rest):
#return Symbol("True")
raise StopGenerator_MatchQ(Symbol("True"))
try:
form.match(yield_func, expr, {}, evaluation)
except StopGenerator_MatchQ, exc:
return exc.value
示例4: __init__
def __init__(self, form):
self.form = Pattern.create(form)
示例5: __init__
def __init__(self, pattern, system=False):
super(BaseRule, self).__init__()
self.pattern = Pattern.create(pattern)
self.system = system
示例6: __init__
def __init__(self, pattern, system=False):
self.pattern = Pattern.create(pattern)
self.system = system