Created
September 2, 2015 05:46
-
-
Save ghedamat/d7f66c8434fb4fcbd2e6 to your computer and use it in GitHub Desktop.
elm baby steps
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
reduce : (a -> a -> a -> a) -> a -> Tree a -> a | |
reduce f base tree = | |
case tree of | |
Empty -> base | |
Node v left right -> | |
f v | |
(reduce f base left) | |
(reduce f base right) | |
sum tree = | |
let f a b c = List.sum [a,b,c] | |
in | |
reduce f 0 tree | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment