我试图将计算“a”的 Adler-32 哈希的 Haskell 代码转换为 Frege,但得到的是 6422626 而不是 300286872
摘自http://book.realworldhaskell.org/read/functional-programming.html上的 Haskell 代码
adler32_try2 xs = helper (1,0) xs
where helper (a,b) (x:xs) =
let a' = (a + (ord x .&. 0xff)) `mod` base
b' = (a' + b) `mod` base
in helper (a',b') xs
helper (a,b) _ = (b `shiftL` 16) .|. a
摘自https://github.com/Dierk/Real_World_Frege/blob/master/realworld/chapter4/G_Reducing.fr的 Frege 代码
adler32 xs = accuAdler (1,0) xs where
accuAdler (a,b) (y:ys) =
let newA = (a + (ord y `band` 0xff)) `mod` base
newB = (newA + b) `mod` base
in accuAdler (newA, newB) ys
accuAdler (a,b) _ = (b `bshl` 16) `bor` a
运算符的选择是错误的还是有符号/无符号的 32/64 整数属性?