Last active
December 18, 2015 00:19
-
-
Save WillNess/5696168 to your computer and use it in GitHub Desktop.
WhyFP's `redtree` simplified
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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