Skip to content

Instantly share code, notes, and snippets.

@bebraw
Created November 28, 2012 16:02
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 bebraw/4162193 to your computer and use it in GitHub Desktop.
Save bebraw/4162193 to your computer and use it in GitHub Desktop.
Type annotations + QC
define(['../common/annotate', '../math/range', '../functional/map', '../operators/gt'], function(annotate, range, map, gt) {
function chunk(len, a) {
return map(function(k) {
return a.slice(k, k + len);
}, range(0, a.length, len));
}
return annotate(chunk, gt(0), Array);
});
var suite = require('suite.js');
var f = require('funkit/array');
var equals = require('funkit/operators/equals');
suite(f.chunk, function(op, len, arr) {
return equals(f.concat(op(len, arr)), arr);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment