Mein Haskell Code werfen ist wie folgtFunktion Elem Fehler
isNotPrime x = elem 0 map (mod x)[3.. (x-1)]
Wenn kompiliert es zeigt diese Fehler
Couldn't match expected type ‘(t1 -> t1) -> [t1] -> t’
with actual type ‘Bool’
The function ‘elem’ is applied to four arguments,
but its type ‘([a0] -> [b0])
-> ((a0 -> b0) -> [a0] -> [b0]) -> Bool’
has only two
In the expression: elem 0 map (mod x) [3 .. (x - 1)]
In an equation for ‘prime’:
prime x = elem 0 map (mod x) [3 .. (x - 1)]
Mein Verständnis ist, dass Elem zwei Argumente akzeptiert, verstehe ich nicht, wie ich bin Übergeben von 4 Argumenten in dem obigen Code als die Map-Funktion sollte nur eine Liste zurückgeben.
Großartige Erklärung! Vielen Dank. Das funktioniert. – rt88