Created
March 9, 2018 01:21
-
-
Save KirinDave/b549238e612e7ffa33b35ba43b1ee380 to your computer and use it in GitHub Desktop.
This file contains 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
createAndSumTree :: [Int] -> Int | |
createAndSumTree lst = hylo sum build lst where | |
sum (LeafF v) = v | |
sum (NodeF v0 v1) = v0 + v1 | |
build [val] = LeafF val | |
build lst = NodeF l r | |
where (l, r) = splitAt (length lst `div` 2) lst | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment