def preprocess_for_cse(expr, optimizations):
 for (pre, post) in optimizations:
  if (pre is not None):
   expr = pre(expr)
 return expr

def preprocess_for_cse ( expr , optimizations ) : for ( pre , post ) in optimizations : if ( pre is not None ) : expr = pre ( expr ) return expr
preprocess an expression to optimize for common subexpression elimination .