F# how to append/join array2D and combine 1D arrays to array2D

前端 未结 3 1824
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 08:40

in F#, array.append can join two arrays; is there a way to append 2 array2D objects into one or column-wise join several 1-D arrays into one array2D object?

3条回答
  •  迷失自我
    2021-01-18 08:51

    The array2D function will turn any seq<#seq<'T>> into a 'T [,] so it should work for turning a bunch of 1D arrays into a 2D array.

    let arr1 = [| 1; 2; 3 |]
    let arr2 = [| 4; 5; 6 |]
    
    let combined = array2D [| arr1; arr2 |]
    

提交回复
热议问题