f# list map function code example
Example 1: f# list map function
let toUpper = fun c -> System.Char.ToUpper(c)
let allcaps = "sesquipedalian"
|> String.map toUpper
// val allcaps : string = "SESQUIPEDALIAN"
Example 2: f# list map function
let squares = [2; 4; 6; 8]
|> List.map (fun n -> n * n)
// val squares : int list = [4; 16; 36; 64]
Example 3: f# list map function
let f = fun n -> n * n
let squares = [2; 4; 6; 8] |> List.map f
// val squares : int list = [4; 16; 36; 64]