0 people like it.

Copy-set an array

Copy an array into a new one, changing the value at index 42 to 123. Uses "function" and pattern patching.

1: 
2: 
3: 
4: 
Array.mapi
    (function
     | 42 -> fun _ -> 123
     | _ -> id)
module Array

from Microsoft.FSharp.Collections
val mapi : mapping:(int -> 'T -> 'U) -> array:'T [] -> 'U []

Full name: Microsoft.FSharp.Collections.Array.mapi
val id : x:'T -> 'T

Full name: Microsoft.FSharp.Core.Operators.id

More information

Link:http://fssnip.net/8X
Posted:5 years ago
Author:Johann Deneux
Tags: array