本文整理汇总了Python中mathics.core.expression.Expression.flatten_pattern_sequence方法的典型用法代码示例。如果您正苦于以下问题:Python Expression.flatten_pattern_sequence方法的具体用法?Python Expression.flatten_pattern_sequence怎么用?Python Expression.flatten_pattern_sequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathics.core.expression.Expression
的用法示例。
在下文中一共展示了Expression.flatten_pattern_sequence方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: yield_match
# 需要导入模块: from mathics.core.expression import Expression [as 别名]
# 或者: from mathics.core.expression.Expression import flatten_pattern_sequence [as 别名]
def yield_match(vars, rest):
if rest is None:
rest = ([], [])
if 0 < len(rest[0]) + len(rest[1]) == len(expression.get_leaves()):
# continue
return
options = {}
for name, value in list(vars.items()):
if name.startswith('_option_'):
options[name[len('_option_'):]] = value
del vars[name]
new_expression = self.do_replace(expression, vars, options, evaluation)
if new_expression is None:
new_expression = expression
if rest[0] or rest[1]:
result = Expression(expression.get_head(), *(
rest[0] + [new_expression] + rest[1]))
else:
result = new_expression
# Flatten out sequences (important for Rule itself!)
result = result.flatten_pattern_sequence()
if return_list:
result_list.append(result)
# count += 1
if max_list is not None and len(result_list) >= max_list:
# return result_list
raise StopGenerator_BaseRule(result_list)
else:
raise StopGenerator_BaseRule(result)