I am using the Array2D module in f# and want to create a sudoku game board (a 9x9 array) using it. Right now I have something that works and that looks like this:
let createInitialArray = [| [|for x in 1 .. 9 -> createSquare x 1 |];
[|for x in 1 .. 9 -> createSquare x 2 |];
[|for x in 1 .. 9 -> createSquare x 3 |];
[|for x in 1 .. 9 -> createSquare x 4 |];
[|for x in 1 .. 9 -> createSquare x 5 |];
[|for x in 1 .. 9 -> createSquare x 6 |];
[|for x in 1 .. 9 -> createSquare x 7 |];
[|for x in 1 .. 9 -> createSquare x 8 |];
[|for x in 1 .. 9 -> createSquare x 9 |] |]
let sudokuGame = Array2D.init 9 9 ( fun i j -> createInitialArray.[j].[i] )
My question is if there is a better or more compact way to write this?
In MSDN about arrays in general and MSDN about Array2D I've learned that there are a few other functions, for example init, initBased, create and createBased. As I'm still only a few weeks into learning the language I don't see how I can work with them.