[Haskell-cafe] Norvig's Sudoku Solver in Haskell
manu
emmanuel.delaborde at citycampus.com
Sun Aug 26 17:17:38 EDT 2007
> From: Malte Milatz <malte at gmx-topmail.de>
> 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
More information about the Haskell-Cafe
mailing list