如何连接字符串选项列表?
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 |> ????
答案 0 :(得分:8)
首先使用List.choose“提取”列表的某些值:
l |> List.choose id |> String.concat "\n"
请注意,您不需要List.toSeq
,因为seq是IEnumerable的别名,而't list已经实现了它。