【发布时间】:2015-03-20 15:51:44
【问题描述】:
我正在从事 Project Euler #41,这是我解决问题的一部分,我不知道如何绕过 Haskell 期待 [Int] 而不是 [Integer]。 Diglist 工作正常,但我将其包括在内以防错误以某种方式涉及它。
digList :: Integer -> [Integer]
digList n = digList' [] n where
digList' xs n
| n < 10 = n : xs
| otherwise = digList' (lsd : xs) nxt
where
lsd = n `mod` 10
nxt = n `div` 10
isNPandigital :: Integer -> Bool
isNPandigital n = isnp 1 (digList n) where --error on this line
isnp i xs
| i `elem` xs = isnp i $ delete i xs
| i == length (digList n) = null xs
| otherwise = False
错误是:
Couldn't match type `Integer' with `Int'
Expected type: [Int]
Actual type: [Integer]
In the return type of a call of `digList'
In the second argument of `isnp', namely `(digList n)'
In the expression: isnp 1 (digList n)
【问题讨论】:
标签: haskell