Skip to content

Instantly share code, notes, and snippets.

@WillNess
Last active December 18, 2015 00:19
Show Gist options
  • Select an option

  • Save WillNess/5696168 to your computer and use it in GitHub Desktop.

Select an option

Save WillNess/5696168 to your computer and use it in GitHub Desktop.
WhyFP's `redtree` simplified
redtree f g a (Node label subtrees) = f label (redtree' f g a subtrees)
redtree' f g a ((:) subtree rest) = g (redtree f g a subtree) (redtree' f g a rest)
redtree' f g a [] = a
**IS**
redtree f g a (Node label subtrees) = f label $ reduce (g . redtree f g a) a subtrees
or
redtree f g a (Node label subtrees) = f label . reduce g a . map (redtree f g a) $ subtrees
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment