Skip to content
Snippets Groups Projects
Commit c250450f authored by Allan Blanchard's avatar Allan Blanchard
Browse files

[Extlib] removed filter_map' (List.filter_map)

parent fe5e9dfa
No related branches found
No related tags found
No related merge requests found
......@@ -102,12 +102,6 @@ let replace cmp x l =
| y::l -> if cmp x y then x::l else y :: aux l
in aux l
let filter_map' f filter l=
let rec aux = function
| [] -> []
| x::tl -> let x' = f x in if filter x' then x' :: aux tl else aux tl
in aux l
let rec fold_map f acc = function
| [] -> acc, []
| x::tl ->
......
......@@ -102,8 +102,6 @@ val replace: ('a -> 'a -> bool) -> 'a -> 'a list -> 'a list
@since Neon-20140301
*)
val filter_map': ('a -> 'b) -> ('b -> bool) -> 'a list -> 'b list
val fold_map: ('a -> 'b -> 'a * 'c) -> 'a -> 'b list -> 'a * 'c list
(** Combines [fold_left] and [map] *)
......
......@@ -174,11 +174,11 @@ let mul_int x i =
let mod_integer (o,sum) i =
(* mod everything *)
let o = Integer.e_rem o i in
let sum = Extlib.filter_map'
(fun (d,b) -> Integer.e_rem d i, b)
(fun (d,_b) -> not (Integer.is_zero d))
sum
let non_zero_rem (d, b) =
let rem = Integer.e_rem d i in
if Integer.is_zero rem then None else Some (rem, b)
in
let sum = List.filter_map non_zero_rem sum in
let sum = Terms.(normalize (reorder sum)) in (* order was not preserverd *)
(* We must then ensure that the set of represented offset is < i,
i.e. that the highest possible value is < i.
......
......@@ -455,9 +455,10 @@ module State = struct
Cil_builtins.is_unused_builtin vi
| _ -> false
in
f, Extlib.filter_out is_unused all
let gls = Extlib.filter_out is_unused all in
if gls = [] then None else Some (f, gls)
in
Extlib.filter_map' globals_of_file (fun (_, gl) -> gl <> []) files
List.filter_map globals_of_file files
(** Make and fill the custom model with default values. *)
......
......@@ -18,12 +18,11 @@ class stdlib_visitor = object
in_stdlib := false;
Cil.SkipChildren
| attrparams ->
let headers =
Extlib.filter_map' (fun ap ->
match ap with
| AStr s -> s
| _ -> assert false
) (Extlib.string_suffix ".h") attrparams
let when_header = function
| AStr s when Extlib.string_suffix ".h" s -> Some s
| _ -> None
in
let headers = List.filter_map when_header attrparams
in
in_stdlib := true;
begin
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment