
7 May
2005
7 May
'05
12:05 p.m.
Daniel Carrera
Max Vasin wrote:
But why do you need that? Where do need to make an assumption about the size of the list?
I'm implementing the RC4 algorithm, which requires a state array with 256 elements containing the bytes from 0 to 255. As the algorithm progresses, the elements of the array get shuffled around. This is what drives the pseudo-random number generator. But the size of the state array is always 256. So, you need list of length 256 and then just use it as state of your PRNG. If you want to check list size you have to do it at runtime:
f lst | length lst == 256 -> doWork | otherwise -> fail "length lst must be 256" -- WBR, Max Vasin.