hash
Lib.hash : int -> string -> int * int -> int
Hash function for strings.
An invocation hash i s (j,k)
takes an integer
i
and uses that to construct a function that, given a
string s
, will produce values approximately equally
distributed among the numbers less than i
. The argument
j
gives an index in the string to start from. The
k
argument is an accumulator, which is useful when hashing
a collection of strings.
Never fails.
- hash 13 "ishkabibble" (0,0);
> val it = 5 : int
For better results, the i
parameter should be a
prime.
This is probably not an industrial strength hash function.