mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
fix(list): add the test sorted_diff (sorted_merge l1 l2) l2 = l1
Also fixed a typo.
This commit is contained in:
parent
c030beaf52
commit
e58c5d8f3b
3 changed files with 11 additions and 3 deletions
|
|
@ -771,6 +771,10 @@ let sorted_diff ~cmp l1 l2 =
|
|||
Q.(triple small_nat small_nat int) (fun (n1,n2,x) -> \
|
||||
let l = sorted_diff ~cmp:CCInt.compare (CCList.init n1 (fun _ -> x)) (CCList.init n2 (fun _ -> x)) in \
|
||||
count (CCInt.equal x) l = CCInt.max (n1 - n2) 0)
|
||||
Q.(pair (list small_int) (list small_int)) (fun (l1,l2) -> \
|
||||
let l1 = List.sort CCInt.compare l1 in \
|
||||
let l2 = List.sort CCInt.compare l2 in \
|
||||
l1 = sorted_diff ~cmp:CCInt.compare (sorted_merge ~cmp:CCInt.compare l1 l2) l2)
|
||||
*)
|
||||
|
||||
let sort_uniq ~cmp l = List.sort_uniq cmp l
|
||||
|
|
|
|||
|
|
@ -504,7 +504,9 @@ val sorted_merge : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
|
|||
val sorted_diff : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
|
||||
(** [sorted_diff ~cmp l1 l2] returns the elements in [l1] that are not in [l2].
|
||||
Both lists are assumed to be sorted with respect to [cmp] and
|
||||
duplicate elements are treated individually.
|
||||
duplicate elements are treated individually. It is the left inverse of
|
||||
[sorted_merge]; that is, [sorted_diff ~cmp (sorted_merge ~cmp l1 l2) l2]
|
||||
is always equal to [l1] for sorted lists [l1] and [l2].
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val sort_uniq : cmp:('a -> 'a -> int) -> 'a list -> 'a list
|
||||
|
|
|
|||
|
|
@ -505,9 +505,11 @@ val sorted_merge : cmp:(('a -> 'a -> int) [@keep_label]) -> 'a list -> 'a list -
|
|||
the given comparison function [cmp]. *)
|
||||
|
||||
val sorted_diff : cmp:(('a -> 'a -> int) [@keep_label]) -> 'a list -> 'a list -> 'a list
|
||||
(** [sorted_merge ~cmp l1 l2] returns the elements in [l1] that are not in [l2].
|
||||
(** [sorted_diff ~cmp l1 l2] returns the elements in [l1] that are not in [l2].
|
||||
Both lists are assumed to be sorted with respect to [cmp] and
|
||||
duplicate elements are treated individually.
|
||||
duplicate elements are treated individually. It is the left inverse of
|
||||
[sorted_merge]; that is, [sorted_diff ~cmp (sorted_merge ~cmp l1 l2) l2]
|
||||
is always equal to [l1] for sorted lists [l1] and [l2].
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val sort_uniq : cmp:(('a -> 'a -> int) [@keep_label]) -> 'a list -> 'a list
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue