From a13e17bbbb81e848be72749bec4fb41155aa7514 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 21 Sep 2015 08:46:39 +0600 Subject: Make Vylist.complement return a list rather than list option. Situations when two lists are the same and when they don't have a common part become indistinguishable, but that's rarely needed. --- src/vylist.ml | 4 ++-- src/vylist.mli | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vylist.ml b/src/vylist.ml index dbcf906..8ee1e19 100644 --- a/src/vylist.ml +++ b/src/vylist.ml @@ -31,10 +31,10 @@ let rec insert_after p x xs = let complement xs ys = let rec aux xs ys = match xs, ys with - | [], _ -> Some ys + | [], _ -> ys | _, [] -> assert false (* Can't happen *) | p :: ps, q :: qs -> if p = q then aux ps qs - else None + else [] in if List.length xs < List.length ys then aux xs ys else aux ys xs diff --git a/src/vylist.mli b/src/vylist.mli index 2df1c2f..9135bf6 100644 --- a/src/vylist.mli +++ b/src/vylist.mli @@ -3,5 +3,5 @@ val remove : ('a -> bool) -> 'a list -> 'a list val replace : ('a -> bool) -> 'a -> 'a list -> 'a list val insert_before : ('a -> bool) -> 'a -> 'a list -> 'a list val insert_after : ('a -> bool) -> 'a -> 'a list -> 'a list -val complement : 'a list -> 'a list -> 'a list option +val complement : 'a list -> 'a list -> 'a list val in_list : 'a list -> 'a -> bool -- cgit v1.2.3