From 927e8c3b0ceaee273c6498aeec10240b3d054d70 Mon Sep 17 00:00:00 2001 From: Max Mouratov Date: Mon, 19 May 2014 17:23:32 +0600 Subject: [PATCH] Fix: Enum.uniq should use structural comparison --- src/batEnum.ml | 3 ++- src/batEnum.mli | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/batEnum.ml b/src/batEnum.ml index 01e8bc69f..0ae99036c 100644 --- a/src/batEnum.ml +++ b/src/batEnum.ml @@ -833,13 +833,14 @@ let uniq e = None -> empty () | Some first -> let prev = ref first in - let not_last x = (BatRef.post prev (fun _ -> x)) != x in + let not_last x = (BatRef.post prev (fun _ -> x)) <> x in let result = filter not_last e in push result first; result (*$T List.enum [1;1;2;3;3;2] |> uniq |> List.of_enum = [1;2;3;2] + List.enum ["a";"a";"b";"c";"c";"b"] |> uniq |> List.of_enum = ["a";"b";"c";"b"] *) let dup t = (t, t.clone()) diff --git a/src/batEnum.mli b/src/batEnum.mli index aaba9b49f..c75c0f397 100644 --- a/src/batEnum.mli +++ b/src/batEnum.mli @@ -582,8 +582,8 @@ val merge : ('a -> 'a -> bool) -> 'a t -> 'a t -> 'a t val uniq : 'a t -> 'a t (** [uniq e] returns a duplicate of [e] with repeated values - omitted. (similar to unix's [uniq] command) - It uses physical equality to compare consecutive elements. *) + omitted (similar to unix's [uniq] command). + It uses structural equality to compare consecutive elements. *) val switch : ('a -> bool) -> 'a t -> 'a t * 'a t (** [switch test enum] splits [enum] into two enums, where the first enum have