Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created October 2, 2011 21:21
Show Gist options
  • Save swannodette/1257981 to your computer and use it in GitHub Desktop.
Save swannodette/1257981 to your computer and use it in GitHub Desktop.
redblacknew.cljs
(defn balance [node]
(match [node]
[([:black [:red [:red a x b] y c] z d] |
[:black [:red a x [:red b y c]] z d] |
[:black a x [:red [:red b y c] z d]] |
[:black a x [:red b y [:red c z d]]])] [:red [:black a x b] y [:black c z d]]
:else node))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment