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
// These functions turn nested tuples into flat ones | |
func munge<T, U, V>(_ x: ((T, U), V)) -> (T, U, V) { | |
return (x.0.0, x.0.1, x.1) | |
} | |
func munge<T, U, V>(_ x: (T, (U, V))) -> (T, U, V) { | |
return (x.0, x.1.0, x.1.1) | |
} | |
func munge<T, U, V, W>(_ x: (T, (U, V, W))) -> (T, U, V, W) { | |
return (x.0, x.1.0, x.1.1, x.1.2) | |
} | |
func munge<T, U, V, W>(_ x: ((T, U, V), W)) -> (T, U, V, W) { | |
return (x.0.0, x.0.1, x.0.2, x.1) | |
} | |
func munge<T, U, V, W>(_ x: ((T, U), (V, W))) -> (T, U, V, W) { | |
return (x.0.0, x.0.1, x.1.0, x.1.1) | |
} | |
func munge<T, U, V, W>(_ x: (T, (U, V), W)) -> (T, U, V, W) { | |
return (x.0, x.1.0, x.1.1, x.2) | |
} | |
func munge<T, U, V, W>(_ x: (((T, U), V), W)) -> (T, U, V, W) { | |
return munge((munge(x.0), x.1)) | |
} | |
func munge<T, U, V, W>(_ x: ((T, (U, V)), W)) -> (T, U, V, W) { | |
return munge((munge(x.0), x.1)) | |
} | |
func munge<T, U, V, W>(_ x: (T, (U, (V, W)))) -> (T, U, V, W) { | |
return munge((x.0, munge(x.1))) | |
} | |
func munge<T, U, V, W>(_ x: (T, ((U, V), W))) -> (T, U, V, W) { | |
return munge((x.0, munge(x.1))) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment