Created
January 25, 2014 17:14
-
-
Save st98/8619785 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
| var partition = function (coll, n) { | |
| var i = 0, j; | |
| var len = Math.floor(coll.length / n); | |
| var result = [], res; | |
| for (; i < len; i++) { | |
| res = []; | |
| for (j = 0; j < n; j++) { | |
| res.push(coll[i * n + j]) | |
| } | |
| result.push(res); | |
| } | |
| return result; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment