Skip to content

Compare ​

How two values of a partially ordered type compare: -1, 0 or 1, or NaN when they are incomparable.

Compare(a, b)How two values of a partially ordered type compare: -1, 0 or 1, or NaN when they are incomparable.
Typed signatures
TypePackageApplies
(any, any) -> unknownstructuresalways

Domain: Structures

Details
  • The PartialOrder protocol's member: a type conforms by saying how it compares two of its values.
  • Reflexive, antisymmetric and transitive; a LinearOrder never answers NaN.
  • Under dominance, [3,1,1,1][3,1,1,1] and [2,2,2][2,2,2] are incomparable: NaN.

Examples

Basic #

In a linear order: −1-1, 00 or 11

live ↗
InCompare(3,5)\mathrm{Compare}(3, 5)Out−1-1

[3,1][3,1] dominates [2,2][2,2]

live ↗
InCompare(IntegerPartition⁡([3,1]),IntegerPartition⁡([2,2]))\mathrm{Compare}({\operatorname{IntegerPartition}}([3, 1]), {\operatorname{IntegerPartition}}([2, 2]))Out11
Properties #

[3,1,1,1][3,1,1,1] and [2,2,2][2,2,2] are incomparable under dominance: NaN

live ↗
InCompare(IntegerPartition⁡([3,1,1,1]),IntegerPartition⁡([2,2,2]))\mathrm{Compare}({\operatorname{IntegerPartition}}([3, 1, 1, 1]), {\operatorname{IntegerPartition}}([2, 2, 2]))OutNaN⁡\operatorname{NaN}
About
Examples3

See also: Min, Max, GreatestLowerBound