Contains operations for working with rank 3 arrays.
See also F# Language Guide - Arrays.
Function or value | Description |
Full Usage:
Array3D.create length1 length2 length3 initial
Parameters:
int
-
The length of the first dimension.
length2 : int
-
The length of the second dimension.
length3 : int
-
The length of the third dimension.
initial : 'T
-
The value of the array elements.
Returns: 'T[,,]
The created array.
|
Example
Array3D.create 2 2 3 1Evaluates to a 2x3 array with contents [[[1; 1; 1]; [1; 1; 1]]; [[1; 1; 1]; [1; 1; 1]]]
|
|
Indexer syntax is generally preferred, e.g. let array = Array3D.init 2 3 3 (fun i j k -> 100*i + 10*j + k) array[0,2,1]Evaluates to 11 .
Example
let array = Array3D.init 2 3 3 (fun i j k -> 100*i + 10*j + k) Array3D.get array 0 2 1Evaluates to 21 .
|
Full Usage:
Array3D.init length1 length2 length3 initializer
Parameters:
int
-
The length of the first dimension.
length2 : int
-
The length of the second dimension.
length3 : int
-
The length of the third dimension.
initializer : int -> int -> int -> 'T
-
The function to create an initial value at each index into the array.
Returns: 'T[,,]
The created array.
|
Example
Array3D.init 2 2 3 (fun i j k -> 100*i + 10*j + k)Evaluates to a 2x2x3 array with contents [[[0; 1; 2]; [10; 11; 12]]; [[100; 101; 102]; [110; 111; 112]]]
|
Full Usage:
Array3D.iter action array
Parameters:
'T -> unit
-
The function to apply to each element of the array.
array : 'T[,,]
-
The input array.
|
Example
let inputs = Array3D.init 2 2 3 (fun i j k -> 100*i + 10*j + k) inputs |> Array3D.iter (fun v -> printfn $"value = {v}")Evaluates to unit and prints
value = 0 value = 1 value = 2 value = 10 value = 11 value = 12 value = 100 value = 101 value = 102 value = 110 value = 111 value = 112in the console. |
|
![]() ![]() ![]() ![]() ![]() ![]() Applies the given function to each element of the array. The integer indices passed to the function indicates the index of element.
Example
let inputs = Array3D.init 2 2 3 (fun i j k -> 100*i + 10*j + k) inputs |> Array3D.iteri (fun i j k v -> printfn $"value at ({i},{j},{k}) = {v}")Evaluates to unit and prints
value at (0,0,0) = 0 value at (0,0,1) = 1 value at (0,0,2) = 2 value at (0,1,0) = 10 value at (0,1,1) = 11 value at (0,1,2) = 12 value at (1,0,0) = 100 value at (1,0,1) = 101 value at (1,0,2) = 102 value at (1,1,0) = 110 value at (1,1,1) = 111 value at (1,1,2) = 112in the console. |
Full Usage:
Array3D.length1 array
Parameters:
'T[,,]
-
The input array.
Returns: int
The length of the array in the first dimension.
|
Example
let array = Array3D.init 2 3 4 (fun i j k -> 100*i + 10*j + k) array |> Array3D.length1Evaluates to 2 .
|
Full Usage:
Array3D.length2 array
Parameters:
'T[,,]
-
The input array.
Returns: int
The length of the array in the second dimension.
|
Example
let array = Array3D.init 2 3 4 (fun i j k -> 100*i + 10*j + k) array |> Array3D.length2Evaluates to 3 .
|
Full Usage:
Array3D.length3 array
Parameters:
'T[,,]
-
The input array.
Returns: int
The length of the array in the third dimension.
|
Example
let array = Array3D.init 2 3 4 (fun i j k -> 100*i + 10*j + k) array |> Array3D.length3Evaluates to 4 .
|
Full Usage:
Array3D.map mapping array
Parameters:
'T -> 'U
-
The function to transform each element of the array.
array : 'T[,,]
-
The input array.
Returns: 'U[,,]
The array created from the transformed elements.
|
![]() ![]() ![]() ![]() ![]() ![]() Builds a new array whose elements are the results of applying the given function to each of the elements of the array. For non-zero-based arrays the basing on an input array will be propagated to the output array.
Example
let inputs = Array3D.init 2 3 3 (fun i j k -> 100*i + 10*j + k) inputs |> Array3D.map (fun v -> 2 * v)Evaluates to a 2x3x3 array with contents [[[0; 2; 4]; [20; 22; 24]]; [[200; 202; 204]; [220; 222; 224]]]
|
|
![]() ![]() ![]() ![]() ![]() ![]() Builds a new array whose elements are the results of applying the given function to each of the elements of the array. The integer indices passed to the function indicates the element being transformed. For non-zero-based arrays the basing on an input array will be propagated to the output array.
Example
let inputs = Array3D.zeroCreate 2 3 3 inputs |> Array3D.mapi (fun i j k v -> 100*i + 10*j + k)Evaluates to a 2x3x3 array with contents [[[0; 2; 4]; [20; 22; 24]]; [[200; 202; 204]; [220; 222; 224]]]
|
Full Usage:
Array3D.set array index1 index2 index3 value
Parameters:
'T[,,]
-
The input array.
index1 : int
-
The index along the first dimension.
index2 : int
-
The index along the second dimension.
index3 : int
-
The index along the third dimension.
value : 'T
-
The value to set at the given index.
|
![]() ![]() ![]() ![]() ![]() ![]() Sets the value of an element in an array. You can also use the syntax 'array.[index1,index2,index3] <- value'. Indexer syntax is generally preferred, e.g. let array = Array3D.zeroCreate 2 3 3 array[0,2,1] < 4.0Evaluates to 11 .
Example
let array = Array3D.zeroCreate 2 3 3 Array3D.set array 0 2 1 4.0After evaluation array is a 2x3x3 array with contents [[[0.0; 0.0; 0.0]; [0.0; 4.0; 0.0]]; [[0.0; 0.0; 0.0]; [0.0; 0.0; 0.0]]]
|
|
Example
let array : float[,,] = Array3D.zeroCreate 2 3 3After evaluation array is a 2x3x3 array with contents all zero.
|