7 let string_of_uri uri = uri;;
10 let l = Str.split (Str.regexp "/") uri in
11 let name_suf = List.nth l (List.length l - 1) in
12 List.hd (Str.split (Str.regexp "\.") name_suf)
15 let depth_of_uri uri =
16 List.length (Str.split (Str.regexp "/") uri) - 2
19 module OrderedStrings =
22 let compare (s1 : t) (s2 : t) = compare s1 s2
26 module SetOfStrings = Map.Make(OrderedStrings);;
28 (* Invariant: the map is the identity function, *)
29 (* i.e. (SetOfStrings.find str !set_of_uri) == str *)
30 let set_of_uri = ref SetOfStrings.empty;;
32 let uri_of_string str =
34 SetOfStrings.find str !set_of_uri
37 set_of_uri := SetOfStrings.add str str !set_of_uri ;