简体   繁体   English

F#多维数组理解

[英]F# Multidimensional array comprehensions

Is there a syntax for creating multidimensional array using comprehensions is F#? 是否有使用理解创建多维数组的语法是F#? This is really easy for jagged arrays: 这对于锯齿状数组来说非常简单:

let weights1 = [|
                  [|3.0|]
                  [|1.0|]
               |]

Sure that I can than convert this jagged array to multidimensional array: 当然,我可以将这个锯齿状数组转换为多维数组:

let weights = Array2D.init 2 2 (fun i j -> weights1.[i].[j])

But isn't there a syntax way of doing the same? 但是,有没有一种语法方式做同样的事情?

使用array2D MSDN运算符,传递一系列序列(或锯齿状数组):

array2D [[3.0]; [1.0]]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM