Haskell ambiguous type
Вопрос
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)
has the following problem when i try to run it
<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)
I tried using fromIntegral but i don't think i used correctly as that gives me compilation error. Please help.
The purpose of this is to find all the prime numbers up until num.
Нет правильного решения
Не связан с StackOverflow