node4good / lodash-contrib

The brass buckles on lodash's utility belt
MIT License
122 stars 19 forks source link

`_.permutation` and `_.combination` support for arrays #47

Open bdkent opened 9 years ago

bdkent commented 9 years ago

It would be really useful to support the standard permutation/combination functions on arrays.

Something like:

_.permutations([0, 1], ['a', 'b']) => [ [0, 'a'], [0, 'b'], [1, 'a'], [1, 'b'] ];
_.combinations([1, 2, 3, 4], 2) => [ [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4] ];

These additions have already (and I think unfortunately) been rejected from lodash proper: https://github.com/lodash/lodash/issues/1191 https://github.com/lodash/lodash/issues/1032

I very frequently find the need for them, so I think they belong in lodash-contrib.

Thanks!

refack commented 9 years ago

Accepted as an enhancement. Do you have a PR for this?

jdalton commented 9 years ago

@bdkent You should also :+1: the lodash issues. This helps me keep tabs on user demand for such methods.

mathpere commented 8 years ago

:+1:

frostme commented 8 years ago

:+1:

wassname commented 8 years ago

Here is an implementation for arrays strings and object. It's similar to pythons itertools.product.

Let me know if you want me to make it a PR (and which category it fits into?).

ericmarkmartin commented 7 years ago

👍

TWiStErRob commented 7 years ago

Long-standing...

o0x2a commented 7 years ago

👍

devhyunjae commented 6 years ago

👍 Any updates in here?

wassname commented 4 years ago

I made this into a PR see #56

electic commented 3 years ago

Any plans to merge this?

carafelix commented 7 months ago

merge please

refack commented 7 months ago

Good time to do some housekeeping on this repo 😄 Expect a resolution in the coming days.