source: code/trunk/lib/string_set.ml@ 40

Last change on this file since 40 was 39, checked in by fox, 2 years ago

Read References field; referred by listing; test & tidy documentation

File size: 843 bytes
RevLine 
[2]1include Set.Make(String)
2
[3]3let list_of_csv x = Str.(split (regexp " *, *")) (String.trim x)
[39]4let list_of_ssv x = Str.(split (regexp " +")) (String.trim x)
5
6let of_string ?(separator=list_of_csv) x = of_list (separator x)
7let of_csv_string x = of_string ~separator:list_of_csv x
8let of_ssv_string x = of_string ~separator:list_of_ssv x
9
[2]10let to_string ?(pre="") ?(sep=", ") s =
11 let j a x = match a, x with "", _ -> x | _, "" -> a | _ -> a ^ sep ^ x in
12 fold (fun x acc -> j acc x) s pre
13
14let query string =
15 let partition (include_set, exclude_set) elt =
16 if String.get elt 0 = '!' then (include_set, add String.(sub elt 1 (length elt - 1)) exclude_set)
17 else (add elt include_set, exclude_set) in
18 List.fold_left partition (empty, empty) @@ list_of_csv string
19
20let predicate (inc, exl) set = not (disjoint inc set) && disjoint exl set
Note: See TracBrowser for help on using the repository browser.