Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module type ORDERING = sig
- type t
- val (<) : t -> t -> bool
- val (>) : t -> t -> bool
- val (=) : t -> t -> bool
- val compare : t -> t -> int
- end
- module Int_ordering : ORDERING with type t = int = struct
- type t = int
- let (<) = Pervasives.(<)
- let (>) = Pervasives.(>)
- let (=) = Pervasives.(=)
- let compare = Pervasives.compare
- end
- module String_ordering : ORDERING with type t = string = struct
- type t = string
- let (<) x y = String.compare x y < 0
- let (>) x y = String.compare x y > 0
- let (=) x y = String.compare x y = 0
- let compare = String.compare
- end
- let sort_pair ordering (x, y) =
- let module Ordering = (val ordering : ORDERING) in
- if Ordering.(<) x y then true (x, y) else
- if Ordering.(>) x y then true (y, x) else true (x, y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement