# ? -- comparison operator

## Synopsis

• Usage:
x ? y
• Inputs:
• x
• y
• Outputs:
• One of the symbols symbol <, symbol >, symbol ==, or incomparable, depending (respectively) on whether x < y, x > y, x == y, or x and y are not comparable.

## Description

Many types of objects may be compared. Numbers are handled as one would expect, and strings, lists and sequences are generally compared lexicographically.
 i1 : 3 ? 4 o1 = < o1 : Keyword i2 : "book" ? "boolean" o2 = < o2 : Keyword i3 : 3 ? 3. o3 = == o3 : Keyword i4 : {1,2,3} ? {4,5} o4 = < o4 : Keyword

Polynomials from the same ring may also be compared. The order depends on the monomial order in the ring.
 i5 : R = ZZ[a,b,c] o5 = R o5 : PolynomialRing i6 : a*c ? b^2 o6 = < o6 : Keyword
A set is smaller than another if it is a subset; for tallies, corresponding counts should all be smaller.
 i7 : set {1,2} ? set {2,3} o7 = incomparable o7 : Symbol i8 : set {1,2} ? set {1,2,3} o8 = < o8 : Keyword i9 : tally {1,1,2} ? tally {1,2,3} o9 = incomparable o9 : Symbol i10 : tally {1,1,2} ? tally {1,1,2,3} o10 = < o10 : Keyword

• sort -- sort a list or columns of a matrix
• rsort -- sort a list or matrix in reverse order
• ? Symbol -- view brief documentation of a symbol

## Ways to use symbol ? :

• IndexedVariable ? IndexedVariable
• List ? List
• Symbol ? IndexedVariable
• VirtualTally ? VirtualTally
• ? Command (missing documentation)
• ? Function -- see ? Symbol -- view brief documentation of a symbol
• ? Keyword -- see ? Symbol -- view brief documentation of a symbol
• ? Package -- see ? Symbol -- view brief documentation of a symbol
• ? ScriptedFunctor -- see ? Symbol -- view brief documentation of a symbol
• ? Symbol -- view brief documentation of a symbol
• ? Type -- see ? Symbol -- view brief documentation of a symbol
• Bag ? Bag -- see Bag -- the class of all bags
• CC ? InfiniteNumber (missing documentation)
• Constant ? Constant (missing documentation)
• Constant ? Number (missing documentation)
• InexactNumber ? Constant (missing documentation)
• InfiniteNumber ? CC (missing documentation)
• InfiniteNumber ? RR (missing documentation)
• MonoidElement ? MonoidElement (missing documentation)
• Number ? Constant (missing documentation)
• Option ? Option (missing documentation)
• RR ? InfiniteNumber (missing documentation)
• VirtualTally ? ZZ (missing documentation)
• ZZ ? VirtualTally (missing documentation)

## For the programmer

The object ? is .

This operator may be used as a binary operator in an expression like x?y. The user may install binary methods for handling such expressions with code such as

         X ? Y := (x,y) -> ...

where X is the class of x and Y is the class of y.

This operator may be used as a prefix unary operator in an expression like ?y. The user may install a method for handling such expressions with code such as

           ? Y := (y) -> ...

where Y is the class of y.