def sall(rule, fns=basic_fns):
 (op, new, children, leaf) = map(fns.get, ('op', 'new', 'children', 'leaf'))
 def all_rl(expr):
  if leaf(expr):
   return expr
  else:
   args = map(rule, children(expr))
   return new(op(expr), *args)
 return all_rl

def sall ( rule , fns = basic_fns ) : ( op , new , children , leaf ) = map ( fns . get , ( 'op' , 'new' , 'children' , 'leaf' ) ) def all_rl ( expr ) : if leaf ( expr ) : return expr else : args = map ( rule , children ( expr ) ) return new ( op ( expr ) , * args ) return all_rl
strategic all - apply rule to args .