Skip to content

Instantly share code, notes, and snippets.

@xgrommx
Forked from davidchambers/zip-many.js
Last active August 29, 2015 14:12
Show Gist options
  • Save xgrommx/11e9420b93ca04249eea to your computer and use it in GitHub Desktop.
Save xgrommx/11e9420b93ca04249eea to your computer and use it in GitHub Desktop.
var R = require('ramda');
var zipMany =
R.cond(R.isEmpty,
R.always([]),
R.converge(R.map,
R.flip(R.pluck),
R.pipe(R.head, R.length, R.range(0))));
var zipMany2 = function(lists) {
return R.isEmpty(lists) ? [] :
R.map(R.rPartial(R.pluck, lists), R.range(0, R.length(R.head(lists))));
};
zipMany([['foo', 'bar', 'baz'], [1, 2, 3], ['a', 'b', 'c']]);
// => [ [ 'foo', 1, 'a' ], [ 'bar', 2, 'b' ], [ 'baz', 3, 'c' ] ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment