<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>partition -- partition a set or list by values of a function</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="___Partition_sp_us_sp__Z__Z.html">next</a> | <a href="___Partition.html">previous</a> | <a href="___Partition_sp_us_sp__Z__Z.html">forward</a> | <a href="___Partition.html">backward</a> | up | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <hr/> <div><h1>partition -- partition a set or list by values of a function</h1> <div class="single"><h2>Synopsis</h2> <ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>partition(f,L)</tt></div> </dd></dl> </div> </li> <li><div class="single">Inputs:<ul><li><span><tt>f</tt>, <span>a <a href="___Function.html">function</a></span></span></li> <li><span><tt>L</tt>, <span>a <a href="___Visible__List.html">visible list</a></span>, or <span>a <a href="___Tally.html">tally</a></span></span></li> </ul> </div> </li> <li><div class="single">Outputs:<ul><li><span><span>a <a href="___Hash__Table.html">hash table</a></span>, whose keys are the possible values of the function <tt>f</tt> on the elements of the list, set or tally <tt>L</tt>, and the corresponding value of the hash table is the list, set or tally of elements of <tt>L</tt> which take that value under <tt>f</tt></span></li> </ul> </div> </li> </ul> </div> <div class="single"><h2>Description</h2> <div><table class="examples"><tr><td><pre>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</pre> </td></tr> <tr><td><pre>i2 : partition(odd, L) o2 = HashTable{false => {6, 2, 8, 8, 8}} true => {1, 3, 5, 3, 1} o2 : HashTable</pre> </td></tr> <tr><td><pre>i3 : partition(odd, set L) o3 = HashTable{false => set {2, 6, 8}} true => set {1, 3, 5} o3 : HashTable</pre> </td></tr> <tr><td><pre>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</pre> </td></tr> </table> The following example parititions the generators of an ideal by degree.<table class="examples"><tr><td><pre>i5 : R = QQ[a..f] o5 = R o5 : PolynomialRing</pre> </td></tr> <tr><td><pre>i6 : I = ideal"ab,ade,ac3,d4,b3,adf,f4,e10" 3 4 3 4 10 o6 = ideal (a*b, a*d*e, a*c , d , b , a*d*f, f , e ) o6 : Ideal of R</pre> </td></tr> <tr><td><pre>i7 : partition(f -> first degree f, flatten entries gens I) o7 = HashTable{2 => {a*b} } 3 3 => {a*d*e, b , a*d*f} 3 4 4 4 => {a*c , d , f } 10 10 => {e } o7 : HashTable</pre> </td></tr> </table> </div> </div> <div class="single"><h2>See also</h2> <ul><li><span><a href="_tally.html" title="tally the elements of a list or sequence">tally</a> -- tally the elements of a list or sequence</span></li> <li><span><a href="_partitions.html" title="list the partitions of an integer">partitions</a> -- list the partitions of an integer</span></li> </ul> </div> <div class="waystouse"><h2>Ways to use <tt>partition</tt> :</h2> <ul><li>partition(Function,Tally)</li> <li>partition(Function,VisibleList)</li> </ul> </div> </div> </body> </html>