Reputation: 444
How do I concatenate a list of string option?
let m = [ ""; "12"; "a"; "b"]
// I can join these with
m |> List.toSeq |> String.concat "\n"
// now I got a list of string option list
let l = [Some ""; None; Some "a"; Some "b"]
l |> List.toSeq |> ????
Upvotes: 2
Views: 1301
Reputation: 5049
you first use List.choose to "extract" the Some values of the list :
l |> List.choose id |> String.concat "\n"
Note you don't need List.toSeq
as seq is an alias for IEnumerable and 't list implement it already.
Upvotes: 9