Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Latest commit

 

History

History
91 lines (56 loc) · 2.12 KB

list.map2['t1,'t2,'u]-function-[fsharp].md

File metadata and controls

91 lines (56 loc) · 2.12 KB
title description keywords author manager ms.date ms.topic ms.prod ms.technology ms.assetid
List.map2<'T1,'T2,'U> Function (F#)
List.map2<'T1,'T2,'U> Function (F#)
visual f#, f#, functional programming
dend
danielfe
05/16/2016
language-reference
visual-studio-dev14
devlang-fsharp
aa680673-f521-47b3-bd42-29a526d93904

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

Creates a new list whose elements are the results of applying the given function to the corresponding elements of the two lists pairwise. The lists must have equal lengths.

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

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

Syntax

// Signature:
List.map2 : ('T1 -> 'T2 -> 'U) -> 'T1 list -> 'T2 list -> 'U list

// Usage:
List.map2 mapping list1 list2

Parameters

mapping Type: 'T1 -> 'T2 -> 'U

The function to transform pairs of elements from the input lists.

list1 Type: 'T1list

The first input list.

list2 Type: 'T2list

The second input list.

Return Value

The list of resulting elements.

Exceptions

Exception Condition
ArgumentException Thrown when the input lists differ in length.

Remarks

The two lists list1 and list2 must have the same length. If they don't, an exception is thrown.

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

Example

[!code-fsharpMain]

Output

[5; 7; 9]

Platforms

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

Version Information

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

See Also

Collections.List Module (F#)

Microsoft.FSharp.Collections Namespace (F#)