Std.Ord
View source →Ordering protocol: three-way compare plus total-order helpers.
The compare/2 callback returns one of :lt, :eq, :gt.
Derived lt, le, gt, ge helpers build on that.
Examples
use Std.Ord
compare(1, 2) # => :lt
lt(1, 2) # => true
ge(3, 3) # => true
compare("ada", "grace") # => :lt
Protocols
-
proto Ord(T)Total ordering over
T.
Functions
-
# fn __group__() -> Atom
Group tag consumed by
Cure.Stdlib.Preload. -
# fn compare(a: Int, b: Int) -> Atom
Integer three-way compare.
-
# fn compare(a: Float, b: Float) -> Atom
Float three-way compare (NaNs follow BEAM's term-order).
-
# fn compare(a: String, b: String) -> Atom
String three-way compare.
-
# fn compare(a: Atom, b: Atom) -> Atom
Atom three-way compare.
-
# fn ge(a: T, b: T) -> Bool
Greater-than-or-equal derived from
compare/2. -
# fn gt(a: T, b: T) -> Bool
Strict greater-than derived from
compare/2. -
# fn le(a: T, b: T) -> Bool
Less-than-or-equal derived from
compare/2. -
# fn lt(a: T, b: T) -> Bool
Strict less-than derived from
compare/2.