Predefined Structures in the combstruct Package
Calling Sequence
Parameters
Description
Examples
combstruct[function](struct(args), size=n)
struct
-
one of a predefined list of available structures
args
argument list that corresponds to the structure struct
n
(optional) non-negative integer specifying the size of the object or the string 'allsizes'
Some special combinatorial classes are predefined in the combstruct package. They are Combination or Subset, Permutation, Partition, and Composition.
Combination or Subset:
Combinations (or subsets) of elements
The argument is a set, list, or non-negative integer. In the case of a non-negative integer n, it is treated as the set {1,2,...,n}. The default size is allsizes.
Use the string 'allsizes' when the object is selected from all possible sizes. If the size is not specified, each structure has default behavior.
Permutation:
Permutations of elements
The argument is a set, list, or non-negative integer. In the case of a non-negative integer n, it is treated as the list [1,2,...,n]. The default size is the number of elements in the set/list.
Partition:
Partitions of positive integers into sums of positive integers without regards to order.
The argument is a positive integer. The default size is 'allsizes'.
Composition:
Composition of a positive integer n into a positive integer k parts of size at least 1, where the order of summands is meaningful.
The argument is a positive integer. The default size is allsizes.
Combination and Subset are different names for the same structure.
You can define your own structure that is understood by the functions in the combstruct package. To create the structure Foo, create the procedures `combstruct/count/Foo`, `combstruct/draw/Foo`, `combstruct/allstructs/Foo`, and `combstruct/iterstructs/Foo`.
Each of these functions must take size as their first argument, a non-negative integer, the string allsizes or the string default, with the arguments that your structure needs. Thus, draw⁡Foo⁡x,y,z,size=n invokes `combstruct/draw/Foo`(n, x, y, z).
with⁡combstruct:
Count all possible subsets of 1,2,3.
count⁡Subset⁡1,2,3
8
Draw a combination of 1,2,3,4,5 that has 4 elements.
draw⁡Combination⁡5,size=4
1,2,3,4
Count the permutations of a,a,b, using all three elements.
count⁡Permutation⁡a,a,b
3
Create an iterator over all the permutations of a,a,b that consist of only two elements.
it≔iterstructs⁡Permutation⁡a,a,b,size=2:
Draw any partition of 9.
draw⁡Partition⁡9
2,2,5
List all the compositions of 3 in 2 parts.
allstructs⁡Composition⁡3,size=2
1,2,2,1
See Also
combstruct
combstruct[allstructs]
combstruct[count]
combstruct[draw]
combstruct[iterstructs]
Download Help Document