[Haskell-beginners] Translating imperative algorithms to Haskell

Marc Dominik Migge marcmigge at gmx.net
Fri Feb 19 16:11:11 EST 2010


I recommend you read John Hughe's article "Why Functional Programming
Matters"[1]. As one of his examples he implements alpha-beta-pruning. I'm
not really a Haskell expert, but I think the main difference will be in the
kind of data structures you use to implement the algorithms. Many people
have recommended Chris Okasaki's PhD thesis [2] to me for an in-depth
treatment of the topic.

[1]: http://www.cs.chalmers.se/~rjmh/Papers/whyfp.html<http://www.cs.chalmers.se/%7Erjmh/Papers/whyfp.html>
[2]: http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf<http://www.cs.cmu.edu/%7Erwh/theses/okasaki.pdf>

Best regards,

On Fri, Feb 19, 2010 at 9:07 PM, Mikhail Novikov <freiksenet at gmail.com>wrote:

> Hash: SHA1
> Hello!
> 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/,
> 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
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> iEYEARECAAYFAkt+73cACgkQPHyh4sfuKrl7NgCeKHrIdJbHrSse6z7eRrmAi6ck
> =oUX7
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100219/953fc6d0/attachment.html

More information about the Beginners mailing list