I am a beginner in haskell and I tried to define a simple function for Sieve of Eratosthenes but it says error:
• Couldn't match expected type ‘Bool -> Bool’
with actual type ‘Bool’
• The function ‘or’ is applied to two value arguments,
but its type ‘t Bool -> Bool’ has only one
In the expression: or (mod n x) (divl l x)
In an equation for ‘divl’: divl (n : l) x = or (mod n x) (divl l x)
|
13 | divl (n:l) x = or (mod n x) (divl l x)
erat l [] = l
erat l (x:t) = if divl l x then erat l t else erat (x:t) l
divl (n:l) x = or (mod n x) (divl l x)
divl [] x = True
I tried to write that as an operator with "`" but nothing worked
oris not the boolean OR operator; that's(||).ortakes a list (well,Foldable) of Boolean values and returnsTrueif at least one value isTrue.(Note that
or []is defined to beFalseto preserve the identityor xs || or ys == or (xs ++ ys). As a concrete example,or [] || or [False] == or [False].)