Created
June 9, 2016 09:23
-
-
Save nrolland/46cda27c7f81b1192d5bf5fe70355c64 to your computer and use it in GitHub Desktop.
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
data Tree = Leaf Int | |
| Node Tree Tree deriving Show | |
repmin t = tr | |
where (mn, tr) = walk mn t | |
walk mn (Leaf n) = (n, Leaf mn) | |
walk mn (Node t1 t2) = (n1 `min` n2, Node tr1 tr2) | |
where | |
(n1, tr1) = walk mn t1 | |
(n2, tr2) = walk mn t2 | |
t = Node (Node (Leaf 10) (Leaf 5)) (Node (Leaf 2) (Node (Leaf 0) (Leaf 10))) | |
vmintree = repmin t | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment