Skip to content

Instantly share code, notes, and snippets.

@olalonde
Created April 24, 2014 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olalonde/11267802 to your computer and use it in GitHub Desktop.
Save olalonde/11267802 to your computer and use it in GitHub Desktop.
data Tree = Node Int [Tree] | Leaf Int deriving Show
add :: Tree -> Int
add (Node i []) = i
add (Leaf i) = i
add (Node i trees) = i + sum (map add trees)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment