partition(L,f,I,g)partition(L,f)partition(L,f,I)partition(L,f,g)partition(f,L,I,g)partition(f,L)partition(f,L,I)partition(f,L,g)Output is a HashTable whose keys are the possible values of the function f on the elements of the list, set or tally L and the corresponding value of the hash table is the list, set or tally of elements of L which take that value under f. The optional third argument I is a list whose elements will be included as keys in the return value, allowing empty lists to appear in the partition.
|
|
|
|
|
It is allowed to swap the order of the first two arguments.
|
|
|
|
|
The following example partitions the generators of an ideal by degree.
|
|
|
When the second function argument is provided, it will be applied to the grouped values after the partition is made.
|
This example demonstrates the fact that $x^2 + 1 \equiv 0 \pmod{p}$ is solvable iff $p \equiv 1 \pmod{4}$.
|
|
If you have already assembled a table of data this pattern can be conveniently used to group by one column while focusing in on another.
|
|
|
|
As in use of partition without applying a function to the values, you can provide a List of key-values to ensure appear in the result - possibly with an empty container of values.
|
|
|
|
When applying a function to map the values of the partition of a VirtualTally, the function is applied to the keys of the partitioned tallies and any key collisions are combined.
|
|
|
|
The object partition is a method function.
The source of this document is in /build/reproducible-path/macaulay2-1.26.11+ds/M2/Macaulay2/packages/Macaulay2Doc/functions/partition-doc.m2:114:0.