-
-
Save ChillyBwoy/999695 to your computer and use it in GitHub Desktop.
140byt.es -- Click ↑↑ fork ↑↑ to play!
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
function( | |
a, // input | |
b, // items in each group | |
c, // fillWith | |
d, // placeholder - index | |
e // placeholder - result | |
){ | |
d = -b, // set index | |
e = []; // init result with an empty array | |
if (b > 0) // if items in group great than 0 | |
for (;(d += b) < a.length;) { // while index less than size of input array | |
var s = a.slice(d, d + b); // create group | |
while(s.length < b)s.push(c||null); // if size of group less than items in group - fill it with "fillWith" | |
e.push(s); // add element to the result | |
} | |
return e | |
} |
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
function(a,b,c,d,e){d=-b,e=[];if(b>0)for(;(d+=b)<a.length;){var s=a.slice(d,d+b);while(s.length<b)s.push(c||null);e.push(s)}return e} |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
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
{ | |
"name": "inGroupsOf", | |
"description": "implementation of inGroupsOf function from prototype.js", | |
"keywords": [ | |
"140bytes", | |
"enumerable", | |
"groups", | |
"array", | |
"prototype.js" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment