把合并成字符串
把合并成字符串
let a1 = seq ["aa";"bb"];;
let a2 = seq ["aa"];;
let a3 = Seq.empty;;
reduce 对于空序列就不容易处理了。
let b1 = a1 |> Seq.reduce(fun a b -> a + "," + b);;
let b2 = a2 |> Seq.reduce(fun a b -> a + "," + b);;
let b3 = if (not ( Seq.isEmpty a3)) then
Seq.reduce(fun a b -> a + "," + b) a3
else
"" ;;
用 String.concat 就非常直观了、方便了。
let c1 = a1 |> String.concat(",");;
let c2 = a2 |> String.concat(",");;
let c3 = a3 |> String.concat(",");;
作者:hadstj
补充:综合编程 , 其他综合 ,