
NEXT KSET OF NSETName:
ksets of the original nset. This command can be used to generate all of these ksets of an nset for given values of n and k. Each time this command is called for given values of n and k, the next kset of an nset is returned. Note that the first call with given values of n and k has a slightly different syntax than the subsequent calls since the subsequent calls need to specify the most recent kset of an nset generated. The output is an array of size k that identifies the elements included in the kset of an nset.
where <k> is a number or parameter that specifies the size of the kset; <n> is a number or parameter that specifies the number of elements in the set; and <y> is a variable where the kset of an nset is saved. This syntax is used to return the first kset of an nset in the sequence of ksets of an nset.
where <k> is a number or parameter that specifies the size of the kset; <n> is a number or parameter that specifies the number of elements in the set; <yprev> is a variable which contains the most recent kset of an nset; and <y> is a variable where the kset of an nset is saved. This syntax is used to return all ksets of an nset in the sequence of ksets of an nset after the first kset of an nset has been generated.
LET K = 3 LET Y = NEXT KSET OF NSET K N
LET N = 5 LET K = 3 LET NTOT = BINOMIAL(N,K) SET WRITE REWIND OFF SET WRITE DECIMALS 0 WRITE KSET.OUT "ALL KSETS OF AN NSET FOR N = ^N AND K = ^K" LET Y = NEXT KSET OF NSET K N LET YPREV = Y WRITE KSET.OUT "KSET 1:" WRITE KSET.OUT Y WRITE KSET.OUT " " WRITE KSET.OUT " " LOOP FOR L = 2 1 NTOT LET Y = NEXT KSET OF NSET K N YPREV WRITE KSET.OUT "KSET ^L:" WRITE KSET.OUT Y WRITE KSET.OUT " " WRITE KSET.OUT " " LET YPREV = Y END OF LOOPThe file KSET.OUT contains ALL KSETS OF AN NSET FOR N = 5 AND K = 3 KSET 1: 1 2 3 KSET 2: 1 2 4 KSET 3: 1 2 5 KSET 4: 1 3 4 KSET 5: 1 3 5 KSET 6: 1 4 5 KSET 7: 2 3 4 KSET 8: 2 3 5 KSET 9: 2 4 5 KSET 10: 3 4 5
Date created: 1/21/2009 