Conway's Game of Life F#
This is a most elegant solution. I have two small improvements:



let neighboursCount (board: int[,]) x y =
    board.[y..y+2, x..x+2] 
    |&gt; flatten 
    |&gt; Array.indexed
    |&gt; Array.sumBy (fun (i, n) -&gt; if i &lt;&gt; 4 then n else 0)




let expandBoard board =
    let N = (Array2D.length1 board) - 1
    array2D [|
        yield                    [| yield board.[N, N]; yield! board.[N, *]; yield board.[N, 0] |]
        for i in [0..N] do yield [| yield board.[i, N]; yield! board.[i, *]; yield board.[i, 0] |]
        yield                    [| yield board.[0, N]; yield! board.[0, *]; yield board.[N, 0] |]
    |]


Here is N set to (Array2D.length1 board) - 1 because that's the value you're using through out the function.