Skip to content

Instantly share code, notes, and snippets.

@jdiez17
Last active August 29, 2015 14:17
Show Gist options
  • Save jdiez17/1b25281c771b6d6a13d9 to your computer and use it in GitHub Desktop.
Save jdiez17/1b25281c771b6d6a13d9 to your computer and use it in GitHub Desktop.
import Data.Char (ord)
item :: Char -> Int -> Int
item c i = (ord c) * (7 + i) ^ (i + 1)
hash' :: Int -> String -> Int
hash' _ [] = 0
hash' i (x:xs) = item x i + hash' (i + 1) xs
hash :: String -> Int
hash = hash' 0 -- just for convenience
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment