ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.14k stars 439 forks source link

Is there some kind of "N-Choose-K" view in the library yet? #1123

Open denchat opened 5 years ago

denchat commented 5 years ago

If not, with current specs, is it possible to implement one?

I wonder wheter it should return a range of range of item references or return a range of each current combination cache of a const container?

You may tag this as a feature request.

CaseyCarter commented 5 years ago

Verifying my understanding: this view would present a range of all subsequences of the underlying range with length k?

denchat commented 5 years ago

Yes, all possible combinations of element with length k

Perhaps, there could be 2 versions: naive version and automatic-duplicate-filtered version

beojan commented 4 years ago

I have one here: https://github.com/beojan/range-comb

TheThief commented 3 years ago

permutations is similar to cartesian_product (except with k copies of the same range), but there's no good substitute for combinations in range_v3 as of yet.

It would have been really useful for advent of code this year! As it is I just used cartesian_product, which is less optimal but worked.