Skip to content

Instantly share code, notes, and snippets.

@Abhiroop
Last active October 30, 2017 11:56
Show Gist options
  • Save Abhiroop/ca12f9016ba7cb30f96110f00aef8d1c to your computer and use it in GitHub Desktop.
Save Abhiroop/ca12f9016ba7cb30f96110f00aef8d1c to your computer and use it in GitHub Desktop.
balR :: Tree a -> Tree a
balR (T B t1 y (T R t2 x t3)) = T R t1 y (T B t2 x t3)
balR (T B (T B t1 z t2) y t3) = balance' (T B (T R t1 z t2) y t3)
balR (T B (T R t1@(T B l value r) z (T B t2 u t3)) y t4) =
T R (balance' (T B (T R l value r) z t2)) u (T B t3 y t4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment