【发布时间】:2016-08-21 09:27:26
【问题描述】:
我有以下代码,它实现了筛子或 Eratosthenes:
primeSieve :: Int -> [Int] -- Returns a list of primes up to upperbound
primeSieve upperbound = filter[2..upperbound]
where filter ls indx =
let divisor = (ls!!indx)
let filtered = [x | x <- ls, x `mod` divisor /= 0]
if divisor*divisor >= last filtered
then filtered
else filter filtered (indx+1)
我在第 4 行收到一个解析错误,“可能不正确的缩进或不匹配的括号”。
这是为什么?
【问题讨论】:
标签: haskell