工作,我必须使用xor
功能的问题Data.Bits
模块 像下面 哈斯克尔XOR不是映射
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
代码当我尝试用[1..10]
和[2..11]
的论点也适用andFunc
(参数只是随意阵列)
它的工作原理。 (不写在这里,但orFunc (.|.)
也适用)
,但由于某些原因,xorFunc
不....并说
<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]
你知道为什么吗?
运行环境: GHC 8.2.1无标志 的Windows 10的64位
感谢你们回答我的愚蠢问题:$ –