有没有简单的方法来打印数组的每个元素?(Is there a simple way to print each element of an array?)

编程入门 行业动态 更新时间:2024-10-28 18:33:36
有没有简单的方法来打印数组的每个元素?(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" y

Well, 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"

更多推荐

本文发布于:2023-07-07 09:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1061388.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   方法来   元素   简单   element

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!