From: Malte Milatz <[EMAIL PROTECTED]>
Subject: Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell
Your program was wrapped by your mail client, so you may want to
hpaste
your program for easier digestion.
here it is : http://hpaste.org/2452
Your profiling output suggests that much time is consumed by the
lookup
function. Since you're using (fromJust . lookup) everywhere anyway, a
data structure not envolving the Maybe type is probably a more succint
choice. And why bother with characters and strings?
no rationale except that's what the original Python script did use
newV2 <- case length newCell of
0 -> Nothing
1 -> do let peersOfS = [ s' | s' <- lookup s peers ]
res <- foldM eliminate newV (zip peersOfS
(cycle newCell))
return res
_ -> return newV
The use of “length” here is not an actual performance problem, but
unnecessary. Simply write: case newCell of [] -> ...
[_] -> ...
_ -> ...
The same is valid for your other use of length.
Malte
I see, thanks !
E.D
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe