mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-12 22:10:40 -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
|
||||
in
|
||||
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
|
||||
(headers, cookies)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -102,6 +102,18 @@ let split_on_slash s : _ list =
|
|||
done;
|
||||
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)
|
||||
["a"; "b"] (split_on_slash "/a/b")
|
||||
["coucou"; "lol"] (split_on_slash "/coucou/lol")
|
||||
|
|
|
|||
|
|
@ -40,3 +40,7 @@ val pp_date : Format.formatter -> Unix.tm -> unit
|
|||
for expiration date of cookies.
|
||||
@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