예제 #1
0
파일: pattern.py 프로젝트: 0xffea/Mathics
 def get_wrappings(self, yield_func, items, max_count, expression, attributes, include_flattened=True):
     if len(items) == 1:
         yield_func(items[0])
     else:
         if max_count is None or len(items) <= max_count:
             if 'Orderless' in attributes:
                 for perm in permutations(items):
                     sequence = Expression('Sequence', *perm)
                     sequence.pattern_sequence = True
                     yield_func(sequence)
             else:
                 sequence = Expression('Sequence', *items)
                 sequence.pattern_sequence = True
                 yield_func(sequence)
         if 'Flat' in attributes and include_flattened:
             yield_func(Expression(expression.get_head(), *items))
예제 #2
0
 def get_wrappings(self, yield_func, items, max_count, expression, attributes, include_flattened=True):
     if len(items) == 1:
         yield_func(items[0])
     else:
         if max_count is None or len(items) <= max_count:
             if 'Orderless' in attributes:
                 for perm in permutations(items):
                     sequence = Expression('Sequence', *perm)
                     sequence.pattern_sequence = True
                     yield_func(sequence)
             else:
                 sequence = Expression('Sequence', *items)
                 sequence.pattern_sequence = True
                 yield_func(sequence)
         if 'Flat' in attributes and include_flattened:
             yield_func(Expression(expression.get_head(), *items))