
30 Nov
2008
30 Nov
'08
9:14 p.m.
dan.doel:
Here's a clean-up of my code (it even fits within the line-length limit of my mail client :)). Note that it's pretty much exactly the Python algorithm. When the Python program finds a solution, it prints the board and exits. Since that's evil IO type stuff, we noble functional folk instead set up an exit continuation using callCC, and call it when we find a solution. :)
I haven't bothered testing it against the Python version, but the backtracking solution I wrote with the Logic monad (and Data.Map) took around 50% more time than this.
I've created a wiki page, http://haskell.org/haskellwiki/The_Knights_Tour I note the LogicT version is the shortest so far. -- Don