module Main 
where

import Data.Char
import Data.HashTable
import Data.Int (Int32)

--old version (6.4.2) for comparison
oldHashString :: String -> Int32
oldHashString = fromIntegral . foldl f 0
  where f m c = ord c + (m * 128) `rem` fromIntegral oldprime

-- | A prime larger than the maximum hash table size
oldprime :: Int32
oldprime = 1500007


strings :: [String]
strings = strings' [] ['a'..'z']
  where
  strings' last [] = []
  strings' last (c:cs) = let this = c : (take 1 last) ++ reverse (drop 1 last)
                         in this:(strings' this cs)


hashed :: [(Int32,String)]
hashed = [(hashString s,s) | s <- strings]

--for comparison
oldhashed :: [(Int32,String)]
oldhashed = [(oldHashString s,s) | s <- strings]





