[Haskell-cafe] Pure hashtable library

Bulat Ziganshin bulat.ziganshin at gmail.com
Wed Aug 27 03:41:30 EDT 2008

Hello haskell-cafe,

solving one more task that uses English dictionary, i've thought: why we don't yet have pure hashtable library? There is imperative hashtables, pretty complex as they need to rebuild entire table as it grows. There is also simple assoc lists and tree/trie implementations, but there is no simple non-modifiable hashes.

how should it look:
* hashtable is represented as an array of assoc lists: Array Int [(a,b)]

* interface to extract data from ht is the same as from assoc list:
lookup :: HT a b -> a -> Maybe b

* ht may be built from assoc list. we should just know it's size beforehand in order to create Array of reasonable size. constructor also need a hashing function:

create :: [(a,b)] -> Int -> (a->Int) -> HT a b

given these constraints, it should be just a 10-20 lines of code, and provide much better efficiency than any tree/trie implementations

Best regards,
 Bulat                          mailto:Bulat.Ziganshin at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080827/632eb037/attachment.htm

More information about the Haskell-Cafe mailing list