Table of contents
TOC
Collapse the table of content
Expand the table of content

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

Den Delimarsky|Last Updated: 8/18/2017
|
3 Contributors

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

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

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

Syntax

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

// Usage:
List.map3 mapping list1 list2 list3

Parameters

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

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

list1 Type: 'T1list

The first input list.

list2 Type: 'T2list

The second input list.

list3 Type: 'T3list

The third input list.

Return Value

The list of transformed elements.

Exceptions

ExceptionCondition
ArgumentExceptionThrown when the input lists differ in length.

Remarks

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

Example

let list1 = [1; 2; 3]
let list2 = [4; 5; 6]
let newList = List.map3 (fun x y z -> x + y + z) list1 list2 [2; 3; 4]
printfn "%A" newList

Output

[7; 10; 13]

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#)

© 2017 Microsoft