12/04/27 22:37:08.83
手続き型言語F#で書くと>>547と同じ環境で500世代9秒
let life (field : int[,]) =
let height, width = field.GetLength 0, field.GetLength 1
let result = Array2D.zeroCreate height width
for y = 0 to height - 1 do
for x = 0 to width - 1 do
let mutable s = 0
for y' = y - 1 to y + 1 do
for x' = x - 1 to x + 1 do
s <- s + field.[(y' + height) % height, (x' + width) % width]
result.[y, x] <- match s, field.[y, x] with 4, 1 | 3, _ -> 1 | _ -> 0
result