<?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>? -- comparison operator</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_and.html">next</a> | <a href="__gt_eq.html">previous</a> | <a href="_and.html">forward</a> | <a href="__gt_eq.html">backward</a> | <a href="_operators.html">up</a> | <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> <div><a href="index.html" title="">Macaulay2Doc</a> > <a href="___The_sp__Macaulay2_splanguage.html" title="">The Macaulay2 language</a> > <a href="_operators.html" title="">operators</a> > <a href="__qu.html" title="comparison operator">?</a></div> <hr/> <div><h1>? -- comparison operator</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>x ? y</tt></div> </dd></dl> </div> </li> <li><div class="single">Inputs:<ul><li><span><tt>x</tt></span></li> <li><span><tt>y</tt></span></li> </ul> </div> </li> <li><div class="single">Outputs:<ul><li><span><span>a <a href="___Boolean.html">Boolean value</a></span></span></li> </ul> </div> </li> </ul> </div> <div class="single"><h2>Description</h2> <div>Compares <tt>x</tt> and <tt>y</tt> (of the same type), returning <tt>symbol <</tt>, <tt>symbol ></tt>, <tt>symbol ==</tt>, or <a href="_incomparable.html" title="a result indicating incomparability">incomparable</a>.<p/> Many types of objects may be compared. Numbers are handled as one would expect, and strings, lists and sequences are generally compared lexicographically.<table class="examples"><tr><td><pre>i1 : 3 ? 4 o1 = < o1 : Keyword</pre> </td></tr> <tr><td><pre>i2 : "book" ? "boolean" o2 = < o2 : Keyword</pre> </td></tr> <tr><td><pre>i3 : 3 ? 3. o3 = == o3 : Keyword</pre> </td></tr> <tr><td><pre>i4 : {1,2,3} ? {4,5} o4 = < o4 : Keyword</pre> </td></tr> </table> <p/> Polynomials from the same ring may also be compared. The order depends on the monomial order in the ring.<table class="examples"><tr><td><pre>i5 : R = ZZ[a,b,c] o5 = R o5 : PolynomialRing</pre> </td></tr> <tr><td><pre>i6 : a*c ? b^2 o6 = < o6 : Keyword</pre> </td></tr> </table> A set is smaller than another if it is a subset; for tallies, corresponding counts should all be smaller.<table class="examples"><tr><td><pre>i7 : set {1,2} ? set {2,3} o7 = incomparable o7 : Symbol</pre> </td></tr> <tr><td><pre>i8 : set {1,2} ? set {1,2,3} o8 = < o8 : Keyword</pre> </td></tr> <tr><td><pre>i9 : tally {1,1,2} ? tally {1,2,3} o9 = incomparable o9 : Symbol</pre> </td></tr> <tr><td><pre>i10 : tally {1,1,2} ? tally {1,1,2,3} o10 = < o10 : Keyword</pre> </td></tr> </table> </div> </div> <div class="single"><h2>See also</h2> <ul><li><span><a href="_sort.html" title="sort a list or columns of a matrix">sort</a> -- sort a list or columns of a matrix</span></li> <li><span><a href="_rsort.html" title="sort a list or matrix in reverse order">rsort</a> -- sort a list or matrix in reverse order</span></li> </ul> </div> <div class="waystouse"><h2>Ways to use <tt>?</tt> :</h2> <ul><li>IndexedVariable ? IndexedVariable</li> <li>List ? List</li> <li>Symbol ? IndexedVariable</li> <li>Tally ? Tally</li> <li><span>Bag ? Bag, see <span><a href="___Bag.html" title="the class of all bags">Bag</a> -- the class of all bags</span></span></li> </ul> </div> <div class="waystouse"><h2>For the programmer</h2> <p>The object <a href="__qu.html" title="comparison operator">?</a> is <span>a <a href="___Keyword.html">keyword</a></span>.</p> <div><div><p>This operator may be used as a binary operator in an expression like <tt>x?y</tt>. The user may install <a href="_binary_spmethods.html" title="">binary methods</a> for handling such expressions with code such as</p> <pre> X ? Y := (x,y) -> ...</pre> <p>where <tt>X</tt> is the class of <tt>x</tt> and <tt>Y</tt> is the class of <tt>y</tt>.</p> </div> <div><p>This operator may be used as a prefix unary operator in an expression like <tt>?y</tt>. The user may <a href="_installing_spmethods.html">install a method</a> for handling such expressions with code such as</p> <pre> ? Y := (y) -> ...</pre> <p>where <tt>Y</tt> is the class of <tt>y</tt>.</p> </div> </div> </div> </div> </body> </html>