<?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>subsets(ZZ,ZZ) -- produce all the subsets</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_substituting_spvalues_spfor_spvariables.html">next</a> | <a href="_subsets_lp__Z__Z_rp.html">previous</a> | <a href="_substituting_spvalues_spfor_spvariables.html">forward</a> | <a href="_subsets_lp__Z__Z_rp.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>subsets(ZZ,ZZ) -- produce all the subsets</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>subsets(n,j)</tt></div> </dd></dl> </div> </li> <li><span>Function: <a href="_subsets.html" title="produce all the subsets">subsets</a></span></li> <li><div class="single">Inputs:<ul><li><span><tt>n</tt>, <span>an <a href="___Z__Z.html">integer</a></span></span></li> <li><span><tt>j</tt>, <span>an <a href="___Z__Z.html">integer</a></span></span></li> </ul> </div> </li> <li><div class="single">Outputs:<ul><li><span><span>a <a href="___List.html">list</a></span>, a list of the subsets of <tt>{0, ..., n-1}</tt> that have <tt>j</tt> elements; each subset is provided as a list</span></li> </ul> </div> </li> </ul> </div> <div class="single"><h2>Description</h2> <div><table class="examples"><tr><td><pre>i1 : subsets(7,3) o1 = {{0, 1, 2}, {0, 1, 3}, {0, 2, 3}, {1, 2, 3}, {0, 1, 4}, {0, 2, 4}, {1, ------------------------------------------------------------------------ 2, 4}, {0, 3, 4}, {1, 3, 4}, {2, 3, 4}, {0, 1, 5}, {0, 2, 5}, {1, 2, 5}, ------------------------------------------------------------------------ {0, 3, 5}, {1, 3, 5}, {2, 3, 5}, {0, 4, 5}, {1, 4, 5}, {2, 4, 5}, {3, 4, ------------------------------------------------------------------------ 5}, {0, 1, 6}, {0, 2, 6}, {1, 2, 6}, {0, 3, 6}, {1, 3, 6}, {2, 3, 6}, ------------------------------------------------------------------------ {0, 4, 6}, {1, 4, 6}, {2, 4, 6}, {3, 4, 6}, {0, 5, 6}, {1, 5, 6}, {2, 5, ------------------------------------------------------------------------ 6}, {3, 5, 6}, {4, 5, 6}} o1 : List</pre> </td></tr> </table> If each of the sets is reversed, then the resulting list is in lexicographic order.<table class="examples"><tr><td><pre>i2 : x = reverse \ subsets(6,3) o2 = {{2, 1, 0}, {3, 1, 0}, {3, 2, 0}, {3, 2, 1}, {4, 1, 0}, {4, 2, 0}, {4, ------------------------------------------------------------------------ 2, 1}, {4, 3, 0}, {4, 3, 1}, {4, 3, 2}, {5, 1, 0}, {5, 2, 0}, {5, 2, 1}, ------------------------------------------------------------------------ {5, 3, 0}, {5, 3, 1}, {5, 3, 2}, {5, 4, 0}, {5, 4, 1}, {5, 4, 2}, {5, 4, ------------------------------------------------------------------------ 3}} o2 : List</pre> </td></tr> <tr><td><pre>i3 : sort x === x o3 = true</pre> </td></tr> </table> </div> </div> </div> </body> </html>