Collections.Array2D Module (F#)

Basic operations on 2-dimensional arrays.

Namespace/Module Path: Microsoft.FSharp.Collections

Assembly: FSharp.Core (in FSharp.Core.dll)

module Array2D

Remarks

F# and CLI multi-dimensional arrays are typically zero-based. However, CLI multi-dimensional arrays used in conjunction with external libraries (for examples, libraries associated with Visual Basic) be non-zero based, using a potentially different base for each dimension. The operations in this module will accept such arrays, and the basing on an input array will be propagated to a matching output array on the Array2D.map and Array2D.mapi operations. Non-zero-based arrays can also be created using Array2D.zeroCreateBased, Array2D.createBased and Array2D.initBased.

Values

Value

Description

base1 : 'T [,] -> int

Fetches the base-index for the first dimension of the array.

base2 : 'T [,] -> int

Fetches the base-index for the second dimension of the array.

blit : 'T [,] -> int -> int -> 'T[,] -> int -> int -> int -> int -> unit

Reads a range of elements from the first array and writes them into the second.

copy : 'T [,] -> 'T [,]

Creates a new array whose elements are the same as the input array.

create : int -> int -> 'T -> 'T [,]

Creates an array whose elements are all initially the given value.

createBased : int -> int -> int -> int -> 'T -> 'T [,]

Creates a based array whose elements are all initially the given value.

get : 'T [,] -> int -> int -> 'T

Fetches an element from a 2D array. You can also use the syntax array.[index1,index2].

init : int -> int -> (int -> int -> 'T) -> 'T [,]

Creates an array given the dimensions and a generator function to compute the elements.

initBased : int -> int -> int -> int -> (int -> int -> 'T) -> 'T [,]

Creates a based array given the dimensions and a generator function to compute the elements.

iter : ('T -> unit) -> 'T [,] -> unit

Applies the given function to each element of the array.

iteri : int -> int -> 'T -> unit

Applies the given function to each element of the array. The integer indices passed to the function indicate the index of element.

length1 : 'T [,] -> int

Returns the length of an array in the first dimension.

length2 : 'T [,] -> int

Returns the length of an array in the second dimension.

map : ('T -> 'U) -> 'T [,] -> 'U [,]

Creates a new array whose elements are the results of applying the given function to each of the elements of the array.

mapi : (int -> int -> 'T -> 'U) -> 'T [,] -> 'U [,]

Creates 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 indicate the element being transformed.

rebase : 'T [,] -> 'T [,]

Creates a new array whose elements are the same as the input array but where a non-zero-based input array generates a corresponding zero-based output array.

set : 'T [,] -> int -> int -> 'T -> unit

Sets the value of an element in an array. You can also use the syntax array.[index1,index2] <- value.

zeroCreate : int -> int -> 'T [,]

Creates an array where the entries are initially Unchecked.defaultof<'T>.

zeroCreateBased : int -> int -> int -> int -> 'T [,]

Creates a based array where the entries are initially Unchecked.defaultof<'T>.

Platforms

Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

Version Information

F# Runtime

Supported in: 2.0, 4.0

Silverlight

Supported in: 3

See Also

Reference

Microsoft.FSharp.Collections Namespace (F#)