ord
Ordering
Section titled “Ordering”data OrderingThe result of a three-way comparison: less than, equal, or greater than.
Ordering.flip
Section titled “Ordering.flip”def flip (o : Ordering) : OrderingThe comparison the other way round: LT and GT swap.
Ordering.isLT
Section titled “Ordering.isLT”def isLT (o : Ordering) : BoolWhether it is LT.
Ordering.isEQ
Section titled “Ordering.isEQ”def isEQ (o : Ordering) : BoolWhether it is EQ.
Ordering.isGT
Section titled “Ordering.isGT”def isGT (o : Ordering) : BoolWhether it is GT.
Ordering.isLE
Section titled “Ordering.isLE”def isLE (o : Ordering) : BoolWhether it is LT or EQ.
Ordering.isGE
Section titled “Ordering.isGE”def isGE (o : Ordering) : BoolWhether it is GT or EQ.
Ordering.beq
Section titled “Ordering.beq”def beq (a : Ordering) (b : Ordering) : BoolWhether two results are the same.
Ordering.then
Section titled “Ordering.then”def r#then (a : Ordering) (b : Ordering) : OrderingA comparison by two keys: a unless it is EQ, then b (compare x y |>.then (compare u v)).
def minBy {A : Type} (cmp : A -> A -> Ordering) (a : A) (b : A) : AThe smaller of two values under a comparison (the first when they compare equal).
def maxBy {A : Type} (cmp : A -> A -> Ordering) (a : A) (b : A) : AThe larger of two values under a comparison (the first when they compare equal).
Nat.threeWayStructurally
Section titled “Nat.threeWayStructurally”def Nat.threeWayStructurally (m : Nat) (n : Nat) : OrderingComparison of naturals by structural recursion (for proofs by induction; programs use Nat.threeWay).
Nat.threeWay
Section titled “Nat.threeWay”def Nat.threeWay (m : Nat) (n : Nat) : OrderingComparison of naturals for programs: the accelerated Nat.blt and Nat.beq, constant steps on literals.
Nat.threeWayEqStructurally
Section titled “Nat.threeWayEqStructurally”def Nat.threeWayEqStructurally (m : Nat) (n : Nat) : Nat.threeWay m n = Nat.threeWayStructurally m nThe two comparisons of naturals agree.
Bool.threeWay
Section titled “Bool.threeWay”def Bool.threeWay (a : Bool) (b : Bool) : OrderingComparison of Booleans, false before true.
String.threeWayChars
Section titled “String.threeWayChars”def String.threeWayChars (xs : List Char) (ys : List Char) : OrderingLexicographic comparison of characters by code point; a proper prefix comes first.
String.threeWay
Section titled “String.threeWay”def String.threeWay (a : String) (b : String) : OrderingLexicographic comparison of strings by code point (which is the order of their UTF-8 bytes).
class Ord (A : Type)A total order: compare a b is where a stands relative to b.
ordNat
Section titled “ordNat”instance ordNat : Ord NatNaturals by value.
ordBool
Section titled “ordBool”instance ordBool : Ord BoolBooleans, false first.
ordChar
Section titled “ordChar”instance ordChar : Ord CharCharacters by code point.
ordString
Section titled “ordString”instance ordString : Ord StringStrings lexicographically.
List.mergeBy
Section titled “List.mergeBy”def mergeBy {A : Type} (cmp : A -> A -> Ordering) (fuel : Nat) (xs : List A) (ys : List A) : List ATwo lists sorted by cmp merged; on a tie the element of xs comes first (the merge is stable). fuel only
bounds the recursion for the termination checker.
List.sortWithin
Section titled “List.sortWithin”def sortWithin {A : Type} (cmp : A -> A -> Ordering) (fuel : Nat) (xs : List A) : List AMerge sort within fuel rounds: halves sorted and merged.
List.sortBy
Section titled “List.sortBy”def sortBy {A : Type} (cmp : A -> A -> Ordering) (xs : List A) : List AA list sorted by a comparison, stably (equal elements keep their order).
List.sort
Section titled “List.sort”def sort {A : Type} {{o : Ord A}} (xs : List A) : List AA list sorted by its order, ascending.
List.sortOn
Section titled “List.sortOn”def sortOn {A : Type} {B : Type} {{o : Ord B}} (key : A -> B) (xs : List A) : List AA list sorted by a key of each element, ascending and stably.
List.dropRepeats
Section titled “List.dropRepeats”def dropRepeats {A : Type} {{o : Ord A}} (xs : List A) : List AA sorted list with each run of equal elements kept once.
List.distinct
Section titled “List.distinct”def distinct {A : Type} {{o : Ord A}} (xs : List A) : List AThe distinct elements of a list, ascending.