Compartilhar via


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

Creates a new collection whose elements are the results of applying the given function to the corresponding elements of the three collections simultaneously.

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

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

// 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: 'T1 list

    The first input list.

  • list2
    Type: 'T2 list

    The second input list.

  • list3
    Type: 'T3 list

    The third input list.

Return Value

The list of transformed elements.

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

The following code example illustrates the use of List.map3.

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

Reference

Collections.List Module (F#)

Microsoft.FSharp.Collections Namespace (F#)