Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- instance Num a => Num (Tree a) where
- (+) (Leaf _) x = x
- (+) (Branch l r) x = Branch (l+x) r
- (*) (Leaf a) (Leaf b) = Leaf (a + b)
- (*) (Branch l1 r1) (Branch l2 r2) = Branch (l1*l2) (r1*r2)
- (*) _ _ = error "Undefined"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement