Last active
August 29, 2015 14:02
-
-
Save natefaubion/1f32c376f27a36b637f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function balance { | |
Black(Red(Red(a, x, b), y, c), z, d) => Red(Black(a, x, b), y, Black(c, z, d)), | |
Black(Red(a, x, Red(b, y, c)), z, d) => Red(Black(a, x, b), y, Black(c, z, d)), | |
Black(a, x, Red(Red(b, y, c), z, d)) => Red(Black(a, x, b), y, Black(c, z, d)), | |
Black(a, x, Red(b, y, Red(c, z, d))) => Red(Black(a, x, b), y, Black(c, z, d)), | |
t => t | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function balance(a0) { | |
var r0 = Black.unapply(a0); | |
if (r0 != null && r0.length === 3) { | |
var r1 = r0[0]; | |
var r2 = Red.unapply(r1); | |
if (r2 != null && r2.length === 3) { | |
var r3 = r2[0]; | |
var r4 = Red.unapply(r3); | |
if (r4 != null && r4.length === 3) { | |
var a = r4[0]; | |
var x = r4[1]; | |
var b = r4[2]; | |
var y = r2[1]; | |
var c = r2[2]; | |
var z = r0[1]; | |
var d = r0[2]; | |
return Red(Black(a, x, b), y, Black(c, z, d)); | |
} | |
var r5 = r2[2]; | |
var r6 = Red.unapply(r5); | |
if (r6 != null && r6.length === 3) { | |
var a = r2[0]; | |
var x = r2[1]; | |
var b = r6[0]; | |
var y = r6[1]; | |
var c = r6[2]; | |
var z = r0[1]; | |
var d = r0[2]; | |
return Red(Black(a, x, b), y, Black(c, z, d)); | |
} | |
} | |
var r7 = r0[2]; | |
var r8 = Red.unapply(r7); | |
if (r8 != null && r8.length === 3) { | |
var r9 = r8[0]; | |
var r10 = Red.unapply(r9); | |
if (r10 != null && r10.length === 3) { | |
var a = r0[0]; | |
var x = r0[1]; | |
var b = r10[0]; | |
var y = r10[1]; | |
var c = r10[2]; | |
var z = r8[1]; | |
var d = r8[2]; | |
return Red(Black(a, x, b), y, Black(c, z, d)); | |
} | |
var r11 = r8[2]; | |
var r12 = Red.unapply(r11); | |
if (r12 != null && r12.length === 3) { | |
var a = r0[0]; | |
var x = r0[1]; | |
var b = r8[0]; | |
var y = r8[1]; | |
var c = r12[0]; | |
var z = r12[1]; | |
var d = r12[2]; | |
return Red(Black(a, x, b), y, Black(c, z, d)); | |
} | |
} | |
} | |
var t = a0; | |
return t; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function balance(e) { | |
var a = Black.unapply(e); | |
if (null != a && 3 === a.length) { | |
var c = Red.unapply(a[0]); | |
if (null != c && 3 === c.length) { | |
var d = Red.unapply(c[0]); | |
if (null != d && 3 === d.length) { | |
e = d[0]; | |
var f = d[1], d = d[2], g = c[1], b = c[2], h = a[1], a = a[2]; | |
return Red(Black(e, f, d), g, Black(b, h, a)); | |
} | |
b = Red.unapply(c[2]); | |
if (null != b && 3 === b.length) { | |
return e = c[0], f = c[1], d = b[0], g = b[1], b = b[2], h = a[1], a = a[2], Red(Black(e, f, d), g, Black(b, h, a)); | |
} | |
} | |
c = Red.unapply(a[2]); | |
if (null != c && 3 === c.length) { | |
b = Red.unapply(c[0]); | |
if (null != b && 3 === b.length) { | |
return e = a[0], f = a[1], d = b[0], g = b[1], b = b[2], h = c[1], a = c[2], Red(Black(e, f, d), g, Black(b, h, a)); | |
} | |
var k = Red.unapply(c[2]); | |
if (null != k && 3 === k.length) { | |
return e = a[0], f = a[1], d = c[0], g = c[1], b = k[0], h = k[1], a = k[2], Red(Black(e, f, d), g, Black(b, h, a)); | |
} | |
} | |
} | |
return e; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment