Created
July 7, 2015 17:03
-
-
Save oisdk/b80427a3c2157a00de06 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
extension CollectionType { | |
subscript(i1: Index, i2: Index, rest: Index...) -> PermutationGenerator<Self, [Self.Index]> { | |
get { | |
return PermutationGenerator(elements: self, indices: [i1, i2] + rest) | |
} | |
} | |
} | |
extension Array { | |
subscript(i1: Index, i2: Index, rest: Index...) -> [T] { | |
get { | |
return ([i1, i2] + rest).map{self[$0]} | |
} set(vals) { | |
for (ind, val) in zip([i1, i2] + rest, vals) { | |
self[ind] = val | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment