-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ml
More file actions
31 lines (26 loc) · 687 Bytes
/
Copy pathutils.ml
File metadata and controls
31 lines (26 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(* Utility functions *)
let default d o =
match o with
| None -> d
| Some x -> x
;;
let cond_list c h t =
if c then h::t else t
;;
let is_designer uid dsg_ids =
List.exists (fun (x, _, _, _) -> uid = x) dsg_ids
;;
let designer_string dsg_ids =
match dsg_ids with
| [] -> "nobody"
| [(_, fn, ln, _)] -> Printf.sprintf "%s %s" fn ln
| (_, ffn, lfn, _)::ds -> Printf.sprintf "%s and %s %s" (String.concat ", " (List.map (fun (_, f, l, _) -> Printf.sprintf "%s %s" f l) ds)) ffn lfn
;;
let remove_null l =
let rec remove_null_aux res l =
match l with
| [] -> res
| None::t -> remove_null_aux res t
| Some x::t -> remove_null_aux (x::res) t in
remove_null_aux [] l
;;