I\'m unexpectedly having a bit of trouble with going from a list of \'a option down to a list containing only the elements that are Some.
My initial attempt was:
Simply
List.choose id
as in
> [Some 4; None; Some 2; None] |> List.choose id;;
val it : int list = [4; 2]
List.choose
id
Another way is to use the Option module functions to filter out the Options with values and then create a list of the values:
let concreteTypeList =
optionTypeList
|> List.filter (fun v -> Option.isSome v)
|> List.map (fun v -> Option.get v)