summaryrefslogtreecommitdiff
path: root/src/vylist.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/vylist.ml')
-rw-r--r--src/vylist.ml11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/vylist.ml b/src/vylist.ml
index ec04055..f18801e 100644
--- a/src/vylist.ml
+++ b/src/vylist.ml
@@ -27,3 +27,14 @@ let rec insert_after p x xs =
| [] -> raise Not_found
| y :: ys -> if (p y) then y :: x :: ys
else y :: (insert_after p x ys)
+
+let complement xs ys =
+ let rec aux xs ys =
+ match xs, ys with
+ | [], _ -> Some ys
+ | _, [] -> assert false (* Can't happen *)
+ | p :: ps, q :: qs -> if p = q then aux ps qs
+ else None
+ in
+ if List.length xs < List.length ys then aux xs ys
+ else aux ys xs