diff options
| author | jp | 2020-02-12 17:46:48 +0000 |
|---|---|---|
| committer | jp | 2020-02-12 17:46:48 +0000 |
| commit | ed8bccd927306551f93d5aab8d0e2a92b9e5d227 (patch) | |
| tree | 55bf788c8155f0c7d024f2147f5eb3873729b02a /src/util.ml | |
| parent | 31a65c9b7383d2a87da0fbcf5c265d533146ac23 (diff) | |
| parent | 4a72cb8084237161d0bccc66f27d5fb6d24315e0 (diff) | |
Merge branch 'sail2' of https://github.com/rems-project/sail into sail2
Diffstat (limited to 'src/util.ml')
| -rw-r--r-- | src/util.ml | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/util.ml b/src/util.ml index 2745631c..99f1111f 100644 --- a/src/util.ml +++ b/src/util.ml @@ -143,6 +143,22 @@ let remove_dups compare eq l = in aux [] l' +let lex_ord_list comparison xs ys = + let rec lex_lists xs ys = + match xs, ys with + | x :: xs, y :: ys -> + let c = comparison x y in + if c = 0 then lex_lists xs ys else c + | [], [] -> 0 + | _, _ -> assert false + in + if List.length xs = List.length ys then + lex_lists xs ys + else if List.length xs < List.length ys then + -1 + else + 1 + let rec power i tothe = if tothe <= 0 then 1 @@ -228,7 +244,7 @@ let option_bind f = function | None -> None | Some(o) -> f o -let rec option_binop f x y = match x, y with +let option_binop f x y = match x, y with | Some x, Some y -> Some (f x y) | _ -> None @@ -418,6 +434,7 @@ let termcode n = else "" let bold str = termcode 1 ^ str +let dim str = termcode 2 ^ str let darkgray str = termcode 90 ^ str let red str = termcode 91 ^ str |
