6 people like it.

Minesweeper Tweet

Minesweeper computation Kata as a tweet (140 characters) not counting code to open namespace and to prepare field as a 2D array.

Minesweeper Tweet

1: 
s|>Array2D.mapi(fun x y->function '*'->'*'|_->'0'+char([for i in 0..8->x+i%3-1,y+i/3-1].Count(fun(x,y)->x>=0&&x<n&&y>=0&&y<m&&s.[x,y]='*')))
val s : char [,]

Full name: Script.s
module Array2D

from Microsoft.FSharp.Collections
val mapi : mapping:(int -> int -> 'T -> 'U) -> array:'T [,] -> 'U [,]

Full name: Microsoft.FSharp.Collections.Array2D.mapi
val x : int
val y : int
Multiple items
val char : value:'T -> char (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.char

--------------------
type char = System.Char

Full name: Microsoft.FSharp.Core.char
val i : int
val n : int

Full name: Script.n
val m : int

Full name: Script.m

More information

Link:http://fssnip.net/ce
Posted:12 years ago
Author:Phillip Trelford
Tags: kata , game