datatype SquareContent = Mine | Digit of int | Blank;
datatype Square = Revealed of SquareContent | Concealed of SquareContent;
datatype GameStatus = OnGoing | Success | Failure;
type MineSweeperState = (Square list list * GameStatus);
type matrix = Square list list;
fun createMineSweeperGrid (n:int, mines:(int*int) list)
:(Square list list)=
let
fun createMines (rowCounter:int, colCounter:int
, retGame:Square list list):(Square list list) =
if rowCounter=n then
retGame (* finished all rows, should be n lists of size n*)
else
if colCounter=n then (*finished current row, move on*)
createMines (rowCounter+1, 0, retGame)
else
if (List.exists(fn y => (rowCounter,colCounter) = y) mines) then
createMines (rowCounter+1, 0, retGame@(Concealed of Mine)))
else
createMines (rowCounter+1, 0, retGame@(Concealed of Blank)))
in
createMines (0,0,[])
end
我正在尝试编写一个函数,将我的矿井插入矿井(坐标)列表中的2dm矩阵,我从用户那里收到。 n代表尺寸。 我在标题中收到错误。
请帮助。