Boost logo

Boost Users :

Subject: Re: [Boost-users] generate structs with all combinations of members from a given struct
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-01-30 11:27:57


On 01/30/10 01:41, OvermindDL1 wrote:
> On Sat, Jan 30, 2010 at 12:35 AM, joel falcou <joel.falcou_at_[hidden]> wrote:
>> OvermindDL1 wrote:
>>> Or make a fusion function called like permutation or so?
>>>
>> It's more than permuttion, it's combination but yeah that's the idea.
>
> Er, yeah, whatever the word was, I have been up for near 24 hours. >.>

The OP said:

> There are 15 of these, which is 2^4 -1, where 4 is the number of members in params.

Isn't 2^4 - 1 the number of non-empty subsets of:

   {field1, field2, field3. field4}

? Now, for r fields, the number of
combinations of r fields from a set of n fields is:

   C(n,r) = (n!/(r!(n-r)!)

Summing up for r=1..n gives:

   C(n,1)+C(n,2)+...+C(n,n)

which is 2^n-1 (according to a textbook of mine), as the OP claimed.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net