Export (0) Print
Expand All
Expand Minimize

Array.zip<'T1,'T2> Function (F#)

Combines the two arrays into an array of tuples with two elements. The two arrays must have equal lengths, otherwise ArgumentException is raised.

Namespace/Module Path: Microsoft.FSharp.Collections.Array

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

// Signature:
Array.zip : 'T1 [] -> 'T2 [] -> ('T1 * 'T2) []

// Usage:
Array.zip array1 array2

array1

Type: 'T1 []

The first input array.

array2

Type: 'T2 []

The second input array.

Exception

Condition

ArgumentException

Thrown when the input arrays differ in length.

The array of tupled elements.

This function is named Zip in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.

The following code shows how to use Array.zip.

let array1 = [| 1; 2; 3 |]
let array2 = [| -1; -2; -3 |]
let arrayZip = Array.zip array1 array2
printfn "%A" arrayZip

Output

[|(1, -1); (2, -2); (3, -3)|]

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

Show:
© 2014 Microsoft