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

Yitzchak Gale gale at sefer.org
Sun Aug 26 16:17:14 EDT 2007

Manu wrote:
>> Should I introduce more strictness ? replace lists with more
>> efficient data structures (ByteStrings, Arrays) ?

Derek wrote:
> Yes.  Treating lists like arrays is always a recipe
> for heartbreak.

Here it costs very little - the lists are all short, mostly of
length exactly 9.

> If you did want to try to match the python code exactly
> there are mutable arrays and such.

I think Manu's code is about as exact as you can get
for a direct translation into pure Haskell. You could
emulate Python using imperitive-style Haskell, but that
would be a different sort of port.

If speed is really important for you, there are many
ways to optimize a Haskell program - the techniques
Derek mentioned, and many more, all the way down
to low-level bit fiddling on the bare metal. There are
some great people on this list who are very, very
good at that.

But I personally find that for my own purposes,
pure, simple, clear Haskell is almost always more
than fast enough. And it saves truckloads of
debugging time.


More information about the Haskell-Cafe mailing list