Table of contents
Collapse the table of content
Expand the table of content Function (F#)

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

Creates a new string whose characters are the results of applying a specified function to each of the characters of the input string.

Namespace/Module Path: Microsoft.FSharp.Core.String

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


// Signature: : (char -> char) -> string -> string

// Usage: mapping str


mapping Type: char->char

The function to apply to the characters of the string.

str Type: string

The input string.


ArgumentNullExceptionThrown when the input string is null.

Return Value

The resulting string.


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 rot13 c =
    let upperZero = int 'A' - 1
    let lowerZero = int 'a' - 1
    if System.Char.IsLetter(c) then
        if System.Char.IsUpper(c) then
            char (((int c + 13 - upperZero) % 26) + upperZero)
            char (((int c + 13 - lowerZero) % 26) + lowerZero)
    else c
let test = "The quick sly fox jumped over the lazy brown dog."
printfn "%s" test
printfn "%s" <| ( rot13 test)


The quick sly fox jumped over the lazy brown dog.
Gur dhvpx fyl sbk whzcrq bire gur ynml oebja qbt.


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

Version Information

F# Core Library VersionsF# Core Library Versions

Supported in: 2.0, 4.0, Portable2.0, 4.0, Portable

See Also

Core.String Module (F#)

Microsoft.FSharp.Core Namespace (F#)

© 2020 Microsoft