diff options
author | Fabrice Le Fessant <fabrice@lefessant.net> | 2017-05-10 16:20:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-10 16:20:34 +0200 |
commit | 908a38182752f4052289f661643ee28cc9a6f056 (patch) | |
tree | 043056dd64e8164f72553c88668231bc33442793 /stdlib | |
parent | eb009761d47f44d7d9608f4661700169bbe925e5 (diff) | |
download | ocaml-908a38182752f4052289f661643ee28cc9a6f056.tar.gz |
Fix bug #7513 (#1136)
Add tests List.compare_lengths and List.compare_length_with in tests/lib-list
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/list.ml | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/stdlib/list.ml b/stdlib/list.ml index 664d854d71..5b7b679f58 100644 --- a/stdlib/list.ml +++ b/stdlib/list.ml @@ -475,9 +475,11 @@ let rec compare_lengths l1 l2 = ;; let rec compare_length_with l n = - match l, n with - | [], 0 -> 0 - | [], _ -> if n > 0 then -1 else 1 - | _, 0 -> 1 - | _ :: l, n -> compare_length_with l (n-1) + match l with + | [] -> + if n = 0 then 0 else + if n > 0 then -1 else 1 + | _ :: l -> + if n <= 0 then 1 else + compare_length_with l (n-1) ;; |