invalidset :: Int -> Int -> Int -> [Int]
invalidset _ 0 _ = []
invalidset 0 _ _ = []
invalidset n k 0 = [ z | z <- [1..n], mod z k == 1]
invalidset n k x = [ z |z <- (validset n k (x-1)) , mod (z-1) k == mod(head(invalidset n k (x-1)) k ]
validset :: Int -> Int -> Int -> [Int]
validset _ 0 _ = []
validset 0 _ _ = []
validset n k 0 = [x | x <-[1..n], mod x k /= 1 ]
validset n k x = [z | z <- validset n k (x-1) , elem z (invalidset n k x) == False ]
当我在GHCi中加载此文件时,它在第6行:104行中显示“输入时解析错误”]'“。
(在定义行“invalidset n k x”中说解析错误)
提前致谢。
答案 0 :(得分:1)
只是一个错配)
:
invalidset n k x = [ z |z <- (validset n k (x-1)) , mod (z-1) k == mod(head(invalidset n k (x-1))) k ]
)
(x-1))
个
Here你运行它。