Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding _.combine method that create all possible combinations from given arrays #1788

Closed
wants to merge 3 commits into from

Conversation

@krawaller
Copy link

@krawaller krawaller commented Aug 14, 2014

This pull request implements a feature I've been missing; it returns all possible combinations of elements from the given arrays. Here's an example:

_.combine([1,2,3],["a","b"],[”foo","bar","baz"]);
// => [ [1,"a","foo"],[1,"a","bar"],[1,"a","baz"],[1,"b","foo"],[1,"b","bar"],[1,"b","baz"],[2,"a","foo"],[2,"a","bar"],[2,"a","baz"],[2,"b","foo"],[2,"b","bar"],[2,"b","baz"]]

Somewhat related to zip but not quite the same.

I was surprised to find no previous discussions on this here or on Underscore-contrib - perhaps it's less useful than I thought? I've used it somewhat often, and as the code to perform it is rather messy, I thought it might be a good fit for inclusion.

@jashkenas
Copy link
Owner

@jashkenas jashkenas commented Aug 14, 2014

Cool idea, but I don't think that's quite useful enough for Underscore. Give Underscore-Contrib a try.

Loading

@krawaller
Copy link
Author

@krawaller krawaller commented Aug 14, 2014

Will do, cheers!

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants