Created
July 2, 2015 13:50
-
-
Save oisdk/b0d4b24c7c6206ce1cce 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
extension Array { | |
func splitEvery(nInEach: Int) | |
-> LazySequence<MapSequenceView<StrideTo<Int>, ArraySlice<T>>> { | |
return lazy(stride(from: 0, to: self.count, by: nInEach)).map { | |
from in self[from ..< advance(from, nInEach, self.count)] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment