this behavior may be caused by the fact that your are using only 26 values for letters out of 256 possible numbers. by considering upper and lower case it's 52 letters out of 256, which accounts for about 20%.
52÷256×50000 = 10156.25 (10271) regards oskar On 02/27/2015 03:25 AM, Enrique Sánchez wrote: > Hello, > > I found some strange behaviour in the hash function. > > When applied to numbers, it works ok, but when applied > to strings, it leads to a huge number of collisions. > > An example: > # ========================================================== > > (setq N 50000 > Lnumbers (range 1 N) > Lstrings (mapcar format (range 1 N)) ) > > (prinl "uniq hashed values, using " N " different numbers: " > (length (uniq (mapcar hash Lnumbers))) ) > > (prinl "uniq hashed values, using " N " different strings: " > (length (uniq (mapcar hash Lstrings))) ) > > (bye) > > # ========================================================== > # PRINTED RESULTS: > # ---------------- > # uniq hashed values, using 50000 different numbers: 50000 > # uniq hashed values, using 50000 different strings: 10271 > # ========================================================== > > enrique. > > > > -- UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe
