有没有简单的方法来打印数组的每个元素?(Is there a simple way to print each element of an array?)
let x=[|15..20|]
let y=Array.map f x
printf "%O" y
那么,我有一个类型信息。
有没有办法用“,”的分隔符打印“y”的每个元素,而不必使用for循环?
let x=[|15..20|] let y=Array.map f x printf "%O" yWell, I got a type information.
Is there any way to print each element of "y" with delimiter of ",", while not having to use a for loop?
最满意答案
在System命名空间或F#'native'中使用String.Join :
let x = [| 15 .. 20 |] printfn "%s" (System.String.Join(",", x)) x |> Seq.map string |> String.concat "," |> printfn "%s"Either use String.Join in the System namespace or F# 'native':
let x = [| 15 .. 20 |] printfn "%s" (System.String.Join(",", x)) x |> Seq.map string |> String.concat "," |> printfn "%s"更多推荐
发布评论