我有这个代码它正在工作,但是当我添加这个语句时它不起作用:
do
let r = ....
我收到错误。代码:
paly :: Matrix -> String->Int -> Matrix
paly mat flag 10 =mat
paly mat flag i =do
let a=1
let b=2
.....
if a/=(-1) ||b/=(-1) then
if y==2 then
take x mat ++
[take x (mat !! y) ++ [flag] ++ drop (x + 1) (mat !! x)] ++
drop (y + 1) mat
else if a==2 then
take a mat ++
[take a (mat !! y) ++ [flag] ++ drop (x + 1) (mat !! x)] ++
drop (y + 1) mat
else if b==2 then
--do
--let r = posState mat
take b mat ++
[take x (mat !! y) ++ [flag] ++ drop (x + 1) (mat !! x)] ++
drop (y + 1) mat
else
take c mat ++
[take c (mat !! y) ++ [flag] ++ drop (x + 1) (mat !! x)] ++
drop (y + 1) mat
else
paly mat flag (i+1)
答案 0 :(得分:2)
它看起来像是一个间距问题,但不是修复它,我会告诉你一个更简洁的方法来编写嵌套的ifs
case (a, b, y) of
(-1, -1, _) -> something
(2, _, 2) -> somethingElse
(_, 2, 2) ->yetSomethingElse
_ -> defaultThing
如果以这种方式重写,修复代码将会容易得多。