Members
(inner, constant) EQ :Ordering
The "equals" Ordering
. Equivalent to ===.
Type:
- Ordering
(inner, constant) GT :Ordering
The "greater than" Ordering
. Equivalent to >.
Type:
- Ordering
(inner, constant) LT :Ordering
The "less than" Ordering
. Equivalent to <.
Type:
- Ordering
Methods
(static) compare(a, b) → {Ordering}
Compare two objects and return an Ordering
. Both values must be instances of the Ord
type
class (i.e. they both define a compare
method) and must also be the same data type (or
primitive type). Note that only a single comparison is required to determine the precise ordering
of two objects.
Haskell> compare :: a -> a -> Ordering
Parameters:
Name | Type | Description |
---|---|---|
a |
* | Any object |
b |
* | Any object |
Returns:
The Ordering
value (EQ
, LT
, or GT
)
- Type
- Ordering
Example
const lst1 = list(1,2,3);
const lst2 = list(4,5,6);
compare(lst1, lst2); // => LT
compare(lst2, lst1); // => GT
const tup1 = tuple(1,2);
const tup2 = tuple(2,1);
const tup3 = swap(tup2);
compare(tup1, tup2); // => LT
compare(tup2, tup3); // => GT
compare(tup3, tup1); // => EQ
(static) greaterThan(a, b) → {boolean}
Determine whether one value is greater than another.
Haskell> (>) :: a -> a -> Bool
Parameters:
Name | Type | Description |
---|---|---|
a |
* | Any object |
b |
* | Any object |
Returns:
a > b
- Type
- boolean
(static) greaterThanOrEqual(a, b) → {boolean}
Determine whether one value is greater than or equal to another.
Haskell> (>=) :: a -> a -> Bool
Parameters:
Name | Type | Description |
---|---|---|
a |
* | Any object |
b |
* | Any object |
Returns:
a >= b
- Type
- boolean
(static) lessThan(a, b) → {boolean}
Determine whether one value is less than another.
Haskell> (<) :: a -> a -> Bool
Parameters:
Name | Type | Description |
---|---|---|
a |
* | Any object |
b |
* | Any object |
Returns:
a < b
- Type
- boolean
(static) lessThanOrEqual(a, b) → {boolean}
Determine whether one value is less than or equal to another.
Haskell> (<=) :: a -> a -> Bool
Parameters:
Name | Type | Description |
---|---|---|
a |
* | Any object |
b |
* | Any object |
Returns:
a <= b
- Type
- boolean
(static) max(a, b) → {*}
Return the higher in value of two objects.
Haskell> max :: a -> a -> a
Parameters:
Name | Type | Description |
---|---|---|
a |
* | Any object |
b |
* | Any object |
Returns:
a
or b
, whichever is greater
- Type
- *
Example
const tup1 = tuple(1,2);
const tup2 = tuple(2,1);
const tup3 = swap(tup2);
max(tup1, tup2); // => (2,1)
max(tup2, tup1); // => (2,1)
max(tup3, tup1); // => (1,2)
(static) min(a, b) → {*}
Return the lower in value of two objects.
Haskell> min :: a -> a -> a
Parameters:
Name | Type | Description |
---|---|---|
a |
* | Any object |
b |
* | Any object |
Returns:
a
or b
, whichever is lesser
- Type
- *
Example
const tup1 = tuple(1,2);
const tup2 = tuple(2,1);
const tup3 = swap(tup2);
min(tup1, tup2); // => (1,2)
min(tup2, tup1); // => (1,2)
min(tup3, tup1); // => (1,2)
(static) Ord() → {boolean}
The Ord
type class is used for totally ordered datatypes. Instances of Ord
must define a
compare
method and must also be instances of Eq
.
Parameters:
Type | Description |
---|---|
* | Any object |
Returns:
true
if an object is an instance of Ord
and false
otherwise
- Type
- boolean