Skip to content

Instantly share code, notes, and snippets.

@ChillyBwoy
Forked from 140bytes/LICENSE.txt
Created May 31, 2011 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChillyBwoy/999695 to your computer and use it in GitHub Desktop.
Save ChillyBwoy/999695 to your computer and use it in GitHub Desktop.
140byt.es -- Click ↑↑ fork ↑↑ to play!
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
}
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}
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.
{
"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