Last change
on this file since 75 was 39, checked in by fox, 2 years ago |
Read References field; referred by listing; test & tidy documentation
|
File size:
843 bytes
|
Line | |
---|
1 | include Set.Make(String)
|
---|
2 |
|
---|
3 | let list_of_csv x = Str.(split (regexp " *, *")) (String.trim x)
|
---|
4 | let list_of_ssv x = Str.(split (regexp " +")) (String.trim x)
|
---|
5 |
|
---|
6 | let of_string ?(separator=list_of_csv) x = of_list (separator x)
|
---|
7 | let of_csv_string x = of_string ~separator:list_of_csv x
|
---|
8 | let of_ssv_string x = of_string ~separator:list_of_ssv x
|
---|
9 |
|
---|
10 | let 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 |
|
---|
14 | let 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 |
|
---|
20 | let predicate (inc, exl) set = not (disjoint inc set) && disjoint exl set
|
---|
Note:
See
TracBrowser
for help on using the repository browser.