Ich habe ein Problem der Verwendung von xor
Funktion in Data.Bits
Modul wie ein Code unter Haskell xor nicht für die Zuordnung arbeiten
import Data.Bits
andFunc :: [Int] -> [Int] -> [Int]
andFunc xs ys = zipWith (\x y -> x .&. y) xs ys
xorFunc :: [Int] -> [Int] -> [Int]
xorFunc xs ys = zipWith (\x y -> x xor y) xs ys
Wenn ich versuche, andFunc
mit Argumenten von [1..10]
anzuwenden und [2..11]
(Argumente sind nur willkürlich Array)
es funktioniert. (Schreibt nicht hier, sondern orFunc (.|.)
funktioniert auch)
aber einige Gründe, xorFunc
nicht .... und sagt
<interactive>:74:1: error:
? Non type-variable argument
in the constraint: Enum ((a -> a -> a) -> t -> c)
(Use FlexibleContexts to permit this)
? When checking the inferred type
it :: forall a t c.
(Enum ((a -> a -> a) -> t -> c), Enum t,
Num ((a -> a -> a) -> t -> c), Num t, Bits a) =>
[c]
Wissen Sie, warum?
Laufende Umwelt: GHC 8.2.1 ohne Flags Windows-10 64-Bit-
Danke Jungs für Beantworte meine blöde Frage: $ –