【发布时间】:2012-12-18 05:47:38
【问题描述】:
我正在尝试在 haskell 中编写一个非常简单的函数来根据输入更改列表中的值,如下所示
update_game :: [Int] -> Int -> Int -> [Int]
update_game (x:xs) row take_amnt | row == 1 = x - take_amnt:xs
| row == 2 = x : head(xs) - take_amnt : tail(xs)
| row == 3 = x : head(xs) : last(xs) - take_amnt`
前两种情况正常,但最后一种情况给我带来了问题,我不知道为什么,我得到的错误是:
【问题讨论】:
-
在 Windows 控制台中,您可以通过单击窗口图标、选择“标记”、进行选择并按 Enter 将其复制到剪贴板来复制文本。
标签: list haskell guard list-comprehension take