mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-15 07:16:08 -05:00
filter_map is only available in recent Stdlib
This commit is contained in:
parent
961eb6af65
commit
19ab478d9c
3 changed files with 17 additions and 1 deletions
|
|
@ -396,7 +396,7 @@ module Headers = struct
|
||||||
| _ -> None
|
| _ -> None
|
||||||
in
|
in
|
||||||
let cookies =
|
let cookies =
|
||||||
List.filter_map fn_eq (String.split_on_char ';' v) @ cookies
|
U.filter_map fn_eq (String.split_on_char ';' v) @ cookies
|
||||||
in
|
in
|
||||||
(headers, cookies)
|
(headers, cookies)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,18 @@ let split_on_slash s : _ list =
|
||||||
done;
|
done;
|
||||||
List.rev !l
|
List.rev !l
|
||||||
|
|
||||||
|
let filter_map f l =
|
||||||
|
let rec fn = function
|
||||||
|
| [] -> []
|
||||||
|
| x::l ->
|
||||||
|
begin
|
||||||
|
match f x with
|
||||||
|
| None -> fn l
|
||||||
|
| Some x -> x::fn l
|
||||||
|
end
|
||||||
|
in
|
||||||
|
fn l
|
||||||
|
|
||||||
(*$= & ~printer:Q.Print.(list string)
|
(*$= & ~printer:Q.Print.(list string)
|
||||||
["a"; "b"] (split_on_slash "/a/b")
|
["a"; "b"] (split_on_slash "/a/b")
|
||||||
["coucou"; "lol"] (split_on_slash "/coucou/lol")
|
["coucou"; "lol"] (split_on_slash "/coucou/lol")
|
||||||
|
|
|
||||||
|
|
@ -40,3 +40,7 @@ val pp_date : Format.formatter -> Unix.tm -> unit
|
||||||
for expiration date of cookies.
|
for expiration date of cookies.
|
||||||
@since 0.12
|
@since 0.12
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
val filter_map : ('a -> 'b option) -> 'a list -> 'b list
|
||||||
|
(** filter_map, now in Stdlib
|
||||||
|
@since 0.12 *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue