Created
May 12, 2020 12:44
-
-
Save tarquin-the-brave/3cae6f3afd87303b9de598db29293743 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
levels :: Tree a -> [[a]] | |
sumDepthsTree :: Integral b => Tree a -> b | |
sumDepthsTree = snd . foldl foldFunc (0, 0) . levels | |
foldFunc :: Integral a => (a,a) -> [b] -> (a,a) | |
foldFunc (depth, acc) x = (depth + 1, acc + depth * genericLength x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment