Skip to content

Instantly share code, notes, and snippets.

@gsg
Created October 30, 2016 10:35
Show Gist options
  • Save gsg/00712c488e92fc3f674d09e05b3f3764 to your computer and use it in GitHub Desktop.
Save gsg/00712c488e92fc3f674d09e05b3f3764 to your computer and use it in GitHub Desktop.
let rec filter_map f = function
| [] -> []
| x::xs ->
match f x with
| Some y -> y::filter_map f xs
| None -> filter_map f xs
let list =
filter_map (function `G a -> Some (`G a) | _ -> None)
[`G 0; `F "wat"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment