Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Main where
- data Tree = Leaf Int
- | Node Int Tree Tree
- mkTree :: Int -> Tree
- mkTree i =
- if i <= 0
- then Leaf 1
- else
- let x = (mkTree (i-1))
- y = (mkTree (i-1))
- in Node i x y
- sumTree :: Tree -> Int
- sumTree foo =
- case foo of
- Leaf i -> i
- Node i a b ->
- let tup = par (sumTree a) (sumTree b)
- x = fst tup
- y = snd tup
- in x + y
- gibbon_main = sumTree (mkTree 27)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement