Macaulay2 » Documentation
Packages » Macaulay2Doc :: partition
next | previous | forward | backward | up | index | toc

partition -- partition a set or list by values of a function

Synopsis

Description

i1 : L = {1,3,6,5,3,1,2,8,8,8}

o1 = {1, 3, 6, 5, 3, 1, 2, 8, 8, 8}

o1 : List
i2 : partition(odd, L)

o2 = HashTable{false => {6, 2, 8, 8, 8}}
               true => {1, 3, 5, 3, 1}

o2 : HashTable
i3 : partition(odd, set L)

o3 = HashTable{false => set {2, 6, 8}}
               true => set {1, 3, 5}

o3 : HashTable
i4 : partition(odd, tally L)

o4 = HashTable{false => Tally{2 => 1}}
                              6 => 1
                              8 => 3
               true => Tally{1 => 2}
                             3 => 2
                             5 => 1

o4 : HashTable
i5 : partition (even, {3,3,5},{true,false})

o5 = HashTable{false => {3, 3, 5}}
               true => {}

o5 : HashTable
The following example partitions the generators of an ideal by degree.
i6 : R = QQ[a..f]

o6 = R

o6 : PolynomialRing
i7 : I = ideal"ab,ade,ac3,d4,b3,adf,f4,e10"

                           3   4   3          4   10
o7 = ideal (a*b, a*d*e, a*c , d , b , a*d*f, f , e  )

o7 : Ideal of R
i8 : partition(f -> first degree f, flatten entries gens I)

o8 = HashTable{2 => {a*b}             }
                             3
               3 => {a*d*e, b , a*d*f}
                        3   4   4
               4 => {a*c , d , f }
                       10
               10 => {e  }

o8 : HashTable

See also

Ways to use partition :

For the programmer

The object partition is a method function.