Skip to content

Instantly share code, notes, and snippets.

@ghedamat
Created September 2, 2015 05:46
Show Gist options
  • Save ghedamat/d7f66c8434fb4fcbd2e6 to your computer and use it in GitHub Desktop.
Save ghedamat/d7f66c8434fb4fcbd2e6 to your computer and use it in GitHub Desktop.
elm baby steps
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