【激突】関数型言語 VS オブジェクト指向言語2
■ このスレッドは過去ログ倉庫に格納されています
0547デフォルトの名無しさん
2012/04/27(金) 22:35:14.09let life (field : int[,]) =
let height, width = field.GetLength 0, field.GetLength 1
field |> Array2D.mapi (fun y x c ->
let s =
seq { y - 1 .. y + 1 } |> Seq.sumBy (fun y' ->
seq { x - 1 .. x + 1 } |> Seq.sumBy (fun x' ->
field.[(y' + height) % height , (x' + width) % width]))
match s, field.[y, x] with 4, 1 | 3, _ -> 1 | _ -> 0)
■ このスレッドは過去ログ倉庫に格納されています