Table of contents
Collapse the table of content
Expand the table of content<'Key,'T,'U> Function (F#)

Den Delimarsky|Last Updated: 8/18/2017
1 Contributor

Creates a new collection whose elements are the results of applying the given function to each of the elements of the collection. The key passed to the function indicates the key of element being transformed.

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

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


// Signature: : ('Key -> 'T -> 'U) -> Map<'Key,'T> -> Map<'Key,'U> (requires comparison)

// Usage: mapping table


mapping Type: 'Key -> 'T -> 'U

The function to transform the key/value pairs.

table Type: Map<'Key,'T>

The input map.

Return Value

The resulting map of keys and transformed values.


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


let map1 = Map.ofList [ (1, "One"); (2, "Two"); (3, "Three") ]
let map2 = map1 |> (fun key value -> value.ToUpper())
let map3 = map1 |> (fun key value -> value.ToLower())
printfn "%A" map1
printfn "%A" map2
printfn "%A" map3


map [(1, "One"); (2, "Two"); (3, "Three")]
map [(1, "ONE"); (2, "TWO"); (3, "THREE")]
map [(1, "one"); (2, "two"); (3, "three")]


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.Map Module (F#)

Microsoft.FSharp.Collections Namespace (F#)

© 2020 Microsoft