findMult lst n = [x | x <- lst, x `mod` n == 0]
primes num =
let n = [2..num]
x = ceiling (sqrt num)
nsqrt = [2..x]
not_prime = map (findMult n) nsqrt
in diff2 n (concat not_prime)
当我尝试运行它时出现以下问题
<interactive>:1:0:
Ambiguous type variable `t' in the constraints:
`RealFrac t' arising from a use of `primes' at <interactive>:1:0-8
`Floating t' arising from a use of `primes' at <interactive>:1:0-8
`Integral t' arising from a use of `primes' at <interactive>:1:0-8
Probable fix: add a type signature that fixes these type variable(s)
我尝试使用 fromIntegral 但我认为我使用不正确,因为这给了我编译错误。请帮忙。
这样做的目的是找到直到 num 的所有素数。