Home

F# Collections: Initialyzing an Array Using an Expression

   

Description

Another way to create an array is to provide its values using an expression. To support this, the Array class provides a method named init. Its signature is:

Array.init : int -> (int -> 'T) -> 'T []

Here is an example:

let yCoords = Array.init 8 (fun a -> (2 * a) + 1)
     
 

Home Copyright © 2012-2015, FunctionX Home