Post Reply 
HP49-HP50 Lists of combination
12-19-2022, 02:53 AM
Post: #3
RE: HP49-HP50 Lists of combination
The ListExt library has a DOCOMB function that would be very useful here.

The arguments for DOCOMB are fairly straightforward:

SL3: { the list of n items to combine }
SL2: <the number of choices for each combination [1..n]>
SL1: « an action to perform for each combination »

The "action to perform" can be a null program (« ») if you just want the list elements returned as combinations in a larger list.

So in this case, you would put the following on the stack:
{ x2 x3 x4 x5 x6 x7 }
4
« »


...then execute DOCOMB. The output using the above arguments is:
{
{ x2 x3 x4 x5 }
{ x2 x3 x4 x6 }
{ x2 x3 x4 x7 }
{ x2 x3 x5 x6 }
{ x2 x3 x5 x7 }
{ x2 x3 x6 x7 }
{ x2 x4 x5 x6 }
{ x2 x4 x5 x7 }
{ x2 x4 x6 x7 }
{ x2 x5 x6 x7 }
{ x3 x4 x5 x6 }
{ x3 x4 x5 x7 }
{ x3 x4 x6 x7 }
{ x3 x5 x6 x7 }
{ x4 x5 x6 x7 }
}


There's also a DOPERM that works in a similar fashion for permutations.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP49-HP50 Lists of combination - Gil - 12-18-2022, 11:01 PM
RE: HP49-HP50 Lists of combination - DavidM - 12-19-2022 02:53 AM
RE: HP49-HP50 Lists of combination - Gil - 12-19-2022, 10:38 AM
RE: HP49-HP50 Lists of combination - Gil - 12-19-2022, 01:42 PM
RE: HP49-HP50 Lists of combination - Gil - 12-19-2022, 03:35 PM



User(s) browsing this thread: 1 Guest(s)