1 people like it.

Array2D to one dimension

This is a simple way to flat a two dimensional array in a linear one

1: 
2: 
3: 
4: 
let flat2Darray array2D = 
                seq { for x in [0..(Array2D.length1 array2D) - 1] do 
                          for y in [0..(Array2D.length2 array2D) - 1] do 
                              yield array2D.[x, y] }
val flat2Darray : array2D:'a [,] -> seq<'a>

Full name: Script.flat2Darray
val array2D : 'a [,]
Multiple items
val seq : sequence:seq<'T> -> seq<'T>

Full name: Microsoft.FSharp.Core.Operators.seq

--------------------
type seq<'T> = System.Collections.Generic.IEnumerable<'T>

Full name: Microsoft.FSharp.Collections.seq<_>
val x : int
module Array2D

from Microsoft.FSharp.Collections
val length1 : array:'T [,] -> int

Full name: Microsoft.FSharp.Collections.Array2D.length1
val y : int
val length2 : array:'T [,] -> int

Full name: Microsoft.FSharp.Collections.Array2D.length2
Raw view New version

More information

Link:http://fssnip.net/oq
Posted:2 years ago
Author:Riccardo Terrell
Tags: array2d , array