You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
642 B
OCaml
16 lines
642 B
OCaml
include Set.Make(String)
|
|
|
|
let list_of_csv x = Str.(split (regexp " *, *")) (String.trim x)
|
|
let of_string x = of_list (list_of_csv x)
|
|
let to_string ?(pre="") ?(sep=", ") s =
|
|
let j a x = match a, x with "", _ -> x | _, "" -> a | _ -> a ^ sep ^ x in
|
|
fold (fun x acc -> j acc x) s pre
|
|
|
|
let query string =
|
|
let partition (include_set, exclude_set) elt =
|
|
if String.get elt 0 = '!' then (include_set, add String.(sub elt 1 (length elt - 1)) exclude_set)
|
|
else (add elt include_set, exclude_set) in
|
|
List.fold_left partition (empty, empty) @@ list_of_csv string
|
|
|
|
let predicate (inc, exl) set = not (disjoint inc set) && disjoint exl set
|