Created
October 2, 2012 10:55
-
-
Save rtt/3818158 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
/* | |
* Similar to python's itertools.izip_longest; | |
* takes an array and chunks it according to a given size | |
*/ | |
func chunk(s []interface{}, sz int) [][]interface{} { | |
r := [][]interface{}{} | |
j := len(s) | |
for i := 0; i < j; i+=sz { | |
r = append(r, s[i:i+sz]) | |
} | |
return r | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment