I need to declare a function in F# that takes 2 parameters (row, col) and return an 2-dimensional array of Option (intitializing all elements to be none), but I don't know the right syntax. I've tried something like:
type T =
{
....//my type
}
let create2DArrayOfT (row : int , col: int) Array2D<Option<T>> = Array2D.init<Option<T>> 10 10 (fun -> None)
the signature above is wrong in specifing the return type. So I have 2 questions:
You don't need to specify return type as that will be deduced by type inference. Just use:
type T = {Name : string}
let create2DArrayOfT (row : int , col: int) = Array2D.init<Option<T>> 10 10 (fun _ _ -> None)
UPDATE:
If you want specify return type use:
let create2DArrayOfT (row : int , col: int) : Option<T> [,] = Array2D.init<Option<T>> 10 10 (fun _ _ -> None)