
On Sat, Jun 07, 2014 at 08:04:09PM -0400, Elric wrote:
Hi,
I came across this article: http://unriskinsight.blogspot.co.at/2014/06/fast-functional-goats-lions-and-... a couple of days ago. This compares performance of solving a problem (which I will get to) using the functional constructs alone in languages like C++11 and Java 8. Since, Haskell is my first foray into FP, I thought I should try solving this in Haskell.
Hello Elric, I gave a go at the problem, managed to get a result (23). I attach the .hs file (not my best Haskell, but hopefully clear enough). The crucial point in my solution lies in this lines: carnage :: [Forest] -> [Forest] let wodup = nub aa in -- etc. etc. Which means after every iteration I call |nub| on my list of possible states; nub is a function from |Data.List| and removes duplicate elements from a list. If I omit that nub call, the program doesn't reach a solution (as it is computationally quite inefficient). I think that's the problem with your versions. Let me know if this helps