Last active
December 26, 2016 13:44
-
-
Save deque-blog/eb424ce3f773ff3e5979f3815af871b1 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
treeWalkC :: Tree a -> [a] | |
treeWalkC EmptyTree = [] | |
treeWalkC (Tree root) = treeWalkC' root | |
treeWalkC' :: Node a -> [a] | |
treeWalkC' n = loop n id | |
where | |
loop (Node v cs) cont = loopChildren cs (cont . (v:)) | |
loopChildren [] cont = cont [] | |
loopChildren (c:cs) cont = | |
loop c $ \res -> loopChildren cs (cont . (res ++)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment