1 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.map
    (function
     | 42 -> fun _ -> 123
     | _ -> id)
module Array

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

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

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

More information

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