Returns true
if x
and y
are equivalent, false
otherwise.
Returns true
if x
and y
are equivalent, false
otherwise.
Returns false
if x
and y
are equivalent, true
otherwise.
Returns false
if x
and y
are equivalent, true
otherwise.
Defines a partial order on B
by mapping B
to A
using f
and using A
s
order to order B
.
Defines a partial order on B
by mapping B
to A
using f
and using A
s
order to order B
.
Returns Some(x) if x >= y, Some(y) if x < y, otherwise None.
Returns Some(x) if x <= y, Some(y) if x > y, otherwise None.
Defines a partial order on A
where all arrows switch direction.
Result of comparing x
with y
.
Result of comparing x
with y
. Returns None if operands
are not comparable. If operands are comparable, returns Some[Int]
where the Int sign is:
- negative iff x < y
- zero iff x == y
- positive iff x > y
The
PartialOrder
type class is used to define a partial ordering on some typeA
.A partial order is defined by a relation <=, which obeys the following laws:
- x <= x (reflexivity) - if x <= y and y <= x, then x == y (antisymmetry) - if x <= y and y <= z, then x <= z (transitivity)
To compute both <= and >= at the same time, we use a Double number to encode the result of the comparisons x <= y and x >= y. The truth table is defined as follows:
x <= y x >= y Double true true = 0 (corresponds to x == y) false false = NaN (x and y cannot be compared) true false < 0 (corresponds to x < y) false true > 0 (corresponds to x > y)