+-
...
The brackets in the guard are not balanced, you open
five brackets, and you close
four
brackets. Furthermore variables start with a lowercase, so it should (probably) be
, not
. I think it might be better to use pattern matching to obtain the first and second coordinate, since this will make the code more clean. You furthermore do not need guards to return and . You can replace the function with: [已关闭]
结束了。 这个问题是
不可复制或由错别字造成的。
. 目前不接受回答。

想改进这个问题?
请更新问题,使之成为 题外话 为Stack Overflow。

已关闭

fireShot :: Coordinate -> Field -> Bool
fireShot coord Shipfield
 | nth ( fst(coord)((nth snd(coord)) ShipField) == 1 = True
 | otherwise                                         = False
上月
4
投票

改进这个问题 shipfield Shipfield我想说的是,如果字段中的期望位置是1,则返回true,否则返回false。为什么这段代码不能用?

True False我想说的是,如果字段中的期望位置是1,则返回true,否则返回false。为什么这段代码不起作用? fireShot :: Coordinate -> Field -> Bool fireShot coord Shipfield .