View Single Post
  #11  
Old 01-22-2009, 11:00 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Loriel View Post
I have never felt a stronger urge to throw my chair at some guy through the internet than I am experiencing right now.

I would not even know where to begin to write an associate array in haskell that has any better than O(n) lookups.
Haskell provides the lookup function which works differently on different data structures.

If you do it on a list like [("a", "1"), ("b", "2"), ("c", "3")] it'll return in O(n).

However, if you do it on a Data.Map which are represented as immutable balanced binary trees, it'll give you a O(log(n)).

Those would be the preferred methods since they both provide a purely functional interface, but you can use hash tables as well with an imperative interface in the IO Monad (with a data HashTable) giving you the O(1).
Reply With Quote