def multiplexer(conditions):
 def multiplexer_rl(expr):
  for (key, rule) in conditions.items():
   if key(expr):
    return rule(expr)
 return multiplexer_rl

def multiplexer ( conditions ) : def multiplexer_rl ( expr ) : for ( key , rule ) in conditions . items ( ) : if key ( expr ) : return rule ( expr ) return multiplexer_rl
apply the rule that matches the condition .