Hi,

looking at `The Great Computer Language Shootout' mentioned in another
thread, I wanted to try if Data.HashTable gives better results than
Data.FiniteMap for the spell checker test
http://www.bagley.org/~doug/shootout/bench/spellcheck/

I came up with the attached program.  With data files

http://www.bagley.org/data/shootout/spellcheck/Usr.Dict.Words
http://www.bagley.org/data/shootout/spellcheck/Input

it yields the result

[EMAIL PROTECTED]:~/t> ./a.out < Input 
blooper
cager
cashmere
coming
tablespoonful
zuul

However, the result should be only `zuul'.  Is the problem in
Data.HashTable?  I have tested, 6.0, 6.2, 6.2.20040304.

Greetings,

Carsten

-- 
Carsten Schultz (2:38, 33:47), FB Mathematik, FU Berlin
http://carsten.codimi.de/
PGP/GPG key on the pgp.net key servers, 
fingerprint on my home page.
module Main(main) where
import qualified Data.HashTable as HashTable
import Data.Maybe
import Control.Monad

main = do
         d <- readFile "Usr.Dict.Words"
         t <- HashTable.fromList HashTable.hashString [(k,())| k<-lines d]
         words <- liftM lines getContents
         let lu w = do
                    res <- HashTable.lookup t w
                    case res of 
                             Nothing -> putStrLn w
                             Just _ -> return ()
         sequence_ $ map lu words

Attachment: pgp00000.pgp
Description: PGP signature

_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to