Create an array in F #?

In C # I would write something like

MyType arr = new MyType[10];

      

allocate arr

as an array that has 10 type elements MyType

.

How do I do the same in F # ??

let mutable arr = ?????????????

      

+2


source to share


2 answers


To initialize a default array (like zero or zero) use Array.zeroCreate:

let arr : int array = Array.zeroCreate 10

      



Use Array.init to initialize with a value.

+4


source


Perhaps you might be interested in this discussion , even though it is in the OCaml context.



+2


source







All Articles