Array2D to Array

前端 未结 2 1544
不思量自难忘°
不思量自难忘° 2020-12-17 22:52

I have Array2D of 0 and 1:

let rnd = System.Random()
let a = Array2D.init n n (fun i j  -> int(System.Math.Round(rnd.NextDouble() / index)) )
2条回答
  •  太阳男子
    2020-12-17 23:38

    The function transforming from Array2D to Array is very handy in many situations.

    You can keep it in Array2D module for convenient use.

    module Array2D =
        let toArray (arr: 'T [,]) = arr |> Seq.cast<'T> |> Seq.toArray
    

提交回复
热议问题