#NEWLINE# @ staticmethod #NEWLINE# def reduce( args ) : #NEWLINE# #INDENT# 'Simplify a :class:`SeqMul` using known rules.\n\n        Iterates through all pairs and ask the constituent\n        sequences if they can simplify themselves with any other constituent.\n\n        Notes\n        =====\n\n        adapted from ``Union.reduce``\n\n        ' #NEWLINE# new_args = True #NEWLINE# while new_args : #NEWLINE# #INDENT# for ( id1 , s ) in enumerate ( args ) : #NEWLINE# #INDENT# new_args = False #NEWLINE# for ( id2 , t ) in enumerate ( args ) : #NEWLINE# #INDENT# if ( id1 == id2 ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# new_seq = s . _mul ( t ) #NEWLINE# if ( new_seq is not None ) : #NEWLINE# #INDENT# new_args = [ a for a in args if ( a not in ( s , t ) ) ] #NEWLINE# new_args . append ( new_seq ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if new_args : #NEWLINE# #INDENT# args = new_args #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( len ( args ) == 1 ) : #NEWLINE# #INDENT# return args . pop ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return SeqMul ( args , evaluate = False )