aboutsummaryrefslogtreecommitdiff
path: root/lib/util.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util.ml')
-rw-r--r--lib/util.ml11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/util.ml b/lib/util.ml
index 4089dc03d2..14a40e378b 100644
--- a/lib/util.ml
+++ b/lib/util.ml
@@ -485,6 +485,11 @@ let list_tabulate f len =
in
tabrec 0
+let rec list_make n v =
+ if n = 0 then []
+ else if n < 0 then invalid_arg "list_make"
+ else v::list_make (n-1) v
+
let list_assign l n e =
let rec assrec stk = function
| ((h::t), 0) -> List.rev_append stk (e::t)
@@ -700,6 +705,12 @@ let rec list_filter2 f = function
if f d l then d::dp', l::lp' else p
| _ -> invalid_arg "list_filter2"
+let rec list_map_filter f = function
+ | [] -> []
+ | x::l ->
+ let l' = list_map_filter f l in
+ match f x with None -> l' | Some y -> y::l'
+
let list_subset l1 l2 =
let t2 = Hashtbl.create 151 in
List.iter (fun x -> Hashtbl.add t2 x ()) l2;