Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. instance Num a => Num (BinTree a) where
  2. (+) (Leaf a) x = x
  3. (+) (Branch l r) x = Branch (l + x) r -- (+) l x
  4.  
  5. (*) (Leaf a) (Leaf b) = Leaf (a * b)
  6. (*) (Branch l r) (Branch l1 r1) = Branch (l * l1) (r * r1)
  7. (*) _ _ = error "neponyal"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement