F# Multidimensional Array Types

后端 未结 2 1120
太阳男子
太阳男子 2020-12-30 03:35

What\'s the difference between \'a[,,] and \'a[][][]? They both represent 3-d arrays. It makes me write array3d.[x].[y].[z] instead of

2条回答
  •  臣服心动
    2020-12-30 04:02

    As of F# 3.1 (2013) things are simpler:

    As of F# 3.1, you can decompose a multidimensional array into subarrays of the same or lower dimension. For example, you can obtain a vector from a matrix by specifying a single row or column.

    // Get row 3 from a matrix as a vector:
    matrix.[3, *]
    
    // Get column 3 from a matrix as a vector:
    matrix.[*, 3]
    

    See https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/arrays#array-slicing-and-multidimensional-arrays

提交回复
热议问题