Export (0) Print
Expand All
Expand Minimize

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

Combines the two lists into a list of pairs. The two lists must have equal lengths.

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

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

// Signature:
List.zip : 'T1 list -> 'T2 list -> ('T1 * 'T2) list

// Usage:
List.zip list1 list2

list1

Type: 'T1 list

The first input list.

list2

Type: 'T2 list

The second input list.

A single list containing pairs of matching elements from the input lists.

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 example illustrates the use of List.zip.


let list1 = [ 1; 2; 3 ]
let list2 = [ -1; -2; -3 ]
let listZip = List.zip list1 list2
printfn "%A" listZip


Output

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

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

F# Runtime

Supported in: 2.0, 4.0

Silverlight

Supported in: 3

Community Additions

ADD
Show:
© 2014 Microsoft