Skip to content

Instantly share code, notes, and snippets.

@Abhiroop
Last active October 30, 2017 11:58
Show Gist options
  • Save Abhiroop/2fe7fa3d32a65ddb0a3bee9a75ab7719 to your computer and use it in GitHub Desktop.
Save Abhiroop/2fe7fa3d32a65ddb0a3bee9a75ab7719 to your computer and use it in GitHub Desktop.
balance :: Color -> Tree a -> a -> Tree a -> Tree a
balance B (T R (T R a x b) y c) z d = T R (T B a x b) y (T B c z d)
balance B (T R a x (T R b y c)) z d = T R (T B a x b) y (T B c z d)
balance B a x (T R (T R b y c) z d) = T R (T B a x b) y (T B c z d)
balance B a x (T R b y (T R c z d)) = T R (T B a x b) y (T B c z d)
balance color a x b = T color a x b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment