Skip to content

Instantly share code, notes, and snippets.

View panda01's full-sized avatar

Khalah Jones Golden panda01

View GitHub Profile
@panda01
panda01 / Unflatten
Created November 7, 2013 03:13
Functional unflatten in js
function unflatten(list, count) {
var ret = [];
// For every group
_.range(Math.ceil(list.length/count)).forEach(function(mul) {
ret.push(list.slice(mul*count, mul*count+count));
});
return ret;
}
console.log(unflatten(_.range(1, 13), 3));