[Haskell-cafe] Norvig's Sudoku Solver in Haskell

Yitzchak Gale gale at sefer.org
Sun Aug 26 18:44:58 EDT 2007

I wrote:
>> Perhaps you would gain something if you used Data.Map.!
>> instead of your "lookup".

Manu wrote:
> I'm not sure I understand, do you mean I should have use a strict Map
> constructor ?
> like : Map !key !value ?

No, there is an operator in Data.Map called "!".

> how can it replace the lookup function ?


> import qualified Data.Map as M
> import Data.Map (!)

Then, instead of "lookup k m"
use "m ! k".

>> Other than that, I'm not
>> sure why your code runs slower than mine.

Malte Milatz wrote:
MM> The use of "length" here is not an actual
MM> performance problem...

Maybe not there, but I think Malte's suggestion might
actually improve performance if you do the same
thing a few lines further down, where you wrote:

> case length dPlaces of

By using Malte's idea there instead of length, you might
allow some calculations inside dPlaces to be lazily


More information about the Haskell-Cafe mailing list