本文介绍了F#如何附加/加入array2D并将一维数组组合到array2D的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在F#中,array.append可以连接两个数组;有没有一种方法可以将2个array2D对象附加到一个或按列方式将多个1-D数组附加到一个array2D对象中?

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?

推荐答案

array2D函数会将任何seq<#seq<'T>>转换为'T [,],因此它将一堆1D数组转换为2D数组应该起作用.

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 |]

这篇关于F#如何附加/加入array2D并将一维数组组合到array2D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-01 00:16