def zero_mul_simp(l, index):
 while ((index >= 0) and (index < (len(l) - 1)) and (l[index][0] is l[(index + 1)][0])):
  exp = (l[index][1] + l[(index + 1)][1])
  base = l[index][0]
  l[index] = (base, exp)
  del l[(index + 1)]
  if (l[index][1] == 0):
   del l[index]
   index -= 1

def zero_mul_simp ( l , index ) : while ( ( index >= 0 ) and ( index < ( len ( l ) - 1 ) ) and ( l [ index ] [ 0 ] is l [ ( index + 1 ) ] [ 0 ] ) ) : exp = ( l [ index ] [ 1 ] + l [ ( index + 1 ) ] [ 1 ] ) base = l [ index ] [ 0 ] l [ index ] = ( base , exp ) del l [ ( index + 1 ) ] if ( l [ index ] [ 1 ] == 0 ) : del l [ index ] index -= 1
used to combine two reduced words .