I have to write this Pearson Hash for school, but I never heard of it so it's difficult to imagine how it works. That is makes things more difficult that I learned haskell a long time ago and I almost forgot it.
Here is the thing: They gave me that the syntac of this function will be this:
pearsonHash :: [Int] -> [Int] -> Int
and the algorithm of Pearson Hash is:
h := 0
for each c in C loop
index := h xor c
h := T[index]
end loop
return h
They said, that: Let C be the input sequence of bytes, and h the value to be calculated. And the first parameter of pearson hash should a a predefined T list which contains a permutation of [0..255]
.
There are the test cases:
pearsonHash ([0..127] ++ [255,254..128]) [1..10] == 11
pearsonHash [255,254..0] [ ord c | c <- "Hello" ] == 189
I think they should be True
.
This is just a part of the work (meaning this is only one function from a lot), so I don't want you to solve this instead of me, I just need help how to solve this function because I got stuck with this one.