module Solutions.P56 (symmetric) where
import Problems.BinaryTrees
symmetric :: Tree a -> Bool
symmetric :: forall a. Tree a -> Bool
symmetric Tree a
Empty = Bool
True
symmetric (Branch a
_ Tree a
left Tree a
right) = Tree a -> Tree a -> Bool
forall a b. Tree a -> Tree b -> Bool
mirror Tree a
left Tree a
right
mirror :: Tree a -> Tree b -> Bool
mirror :: forall a b. Tree a -> Tree b -> Bool
mirror Tree a
Empty Tree b
Empty = Bool
True
mirror (Branch a
_ Tree a
l Tree a
r) (Branch b
_ Tree b
l' Tree b
r') = Tree a -> Tree b -> Bool
forall a b. Tree a -> Tree b -> Bool
mirror Tree a
l Tree b
r' Bool -> Bool -> Bool
&& Tree a -> Tree b -> Bool
forall a b. Tree a -> Tree b -> Bool
mirror Tree a
r Tree b
l'
mirror Tree a
_ Tree b
_ = Bool
False