Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
extension SequenceType where Generator.Element: SequenceType {
func transposeAndPad() -> [[Generator.Element.Generator.Element]]? {
var g = self.generate()
return g.next().map {
var gens = GeneratorSequence(g).map{$0.generate()}
return $0.map { fEl in [fEl] + gens.indices.map{gens[$0].next() ?? fEl}}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.