[Haskell-beginners] Translating imperative algorithms to Haskell
freiksenet at gmail.com
Fri Feb 19 15:07:19 EST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Four days ago I decided to try to learn Haskell by participating in Google AI Challenge (http://csclub.uwaterloo.ca/contest/). I went with LYAH and Real-World Haskell and I had no problems with functional core of Haskell, as I have lispy background. The problems begun when I tried to move my code to use different kind of decision algorithms, like negascout or flood fill.
I have found a ready made solution for negascout (http://hackage.haskell.org/packages/archive/game-tree/0.1.0.0/doc/html/src/Data-Tree-Game_tree-Negascout.html), but I was quite shocked by it's complexity, especially considering the relative easy of imperative algorithm.(http://en.wikipedia.org/wiki/Negascout). IMHO it is just TOO extremely complex and hard to read :/
In flood fill situation is similar - I need to track all the colored squares among 4 lines of recursion and I couldn't find a reasonable way to do it without going to infinite recursion or having lots of duplicates.
So basically, I wonder if there is some generic way to transfer imperative algorithms with local state to functional style without making them overly complex.
Thanks a lot, Mikhail
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
-----END PGP SIGNATURE-----
More information about the Beginners