diff options
Diffstat (limited to 'lib/util.ml')
| -rw-r--r-- | lib/util.ml | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/util.ml b/lib/util.ml index 3bac54cf94..95a609378f 100644 --- a/lib/util.ml +++ b/lib/util.ml @@ -63,12 +63,22 @@ let parse_section_path s = (* Lists *) -let intersect l1 l2 = +let list_intersect l1 l2 = List.filter (fun x -> List.mem x l2) l1 -let subtract l1 l2 = +let list_unionq l1 l2 = + let rec urec = function + | [] -> l2 + | a::l -> if List.memq a l2 then urec l else a::urec l + in + urec l1 + +let list_subtract l1 l2 = if l2 = [] then l1 else List.filter (fun x -> not (List.mem x l2)) l1 +let list_subtractq l1 l2 = + if l2 = [] then l1 else List.filter (fun x -> not (List.memq x l2)) l1 + let list_chop n l = let rec chop_aux acc = function | (0, l2) -> (List.rev acc, l2) |
