你能帮我修复这段代码吗?Haskell程序修复
import Data.Char
import Data.List
-- 1 2 3 4 5 6 7 8
colors = [1,2,3,4,5]
--game :: [Integer] -> [Char]
game a = do
let black = test a color
white = (test2 a color) - black
let x = [a] ++ createScore black white
show x
test [] [] = 0
test (x:xs) (y:ys) = if x == y then 1+test xs ys else 0+test xs ys
test2 a b = length (intersection a b)
intersection first second = [n | n <- first , isInfixOf [n] second]
createScore c b = [(take c (repeat 1) ++ take b (repeat 0))]
start = do
a <- getLine
let b = map read $ words a
--print b
game b
start
我有IO和nonIO函数的问题。该计划的 描述:
- 从行读取数据
- 数据转换为INT
- 通话功能的游戏列表(这需要像parametr INT的列表)
- 做一些计算
- 打印得分
- 再次从1开始
问题在功能启动,我不知道如何解决它。
感谢您的帮助。
您应该添加错误消息。 – Nicolas