<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Thank You Ariis,<br>
    <br>
    I was using nub in a wrong way, like so:<br>
    <font face="Courier New, Courier, monospace">meal :: Forest ->
      [Forest]<br>
      meal [] = []<br>
      meal f@[Lion l, Wolf w, Goat g]<br>
        | endState f = []<br>
        | l == 0 = [f] ++ weg<br>
        | w == 0 = [f] ++ leg<br>
        | g == 0 = [f] ++ lew<br>
        | (l /= 0) && (w /= 0) && (g /= 0) = [f] ++ leg
      ++ lew ++ weg<br>
        | otherwise = []<br>
        where<br>
          leg = </font><font face="Courier New, Courier, monospace"><font
        face="Courier New, Courier, monospace">nub $ </font>meal $
      ionEatGoat f<br>
          lew = </font><font face="Courier New, Courier, monospace"><font
        face="Courier New, Courier, monospace">nub $ </font>meal $
      lionEatWolf f<br>
          weg = </font><font face="Courier New, Courier, monospace"><font
        face="Courier New, Courier, monospace">nub $ </font>meal $
      wolfEatGoat f</font><br>
    <br>
    After looking at your solution, I realized I was essentially
    generating every possible state, and THEN trying to remove the
    duplicates, whereas in your solution at each step you remove
    possible duplicates states of the forest and propagate to the next
    step only from there.<br>
    <br>
    Thank You,<br>
    Praveen<br>
    <br>
    <div class="moz-cite-prefix">On 06/08/2014 02:33 AM, Francesco Ariis
      wrote:<br>
    </div>
    <blockquote cite="mid:20140608063356.GA14455@x60s.casa" type="cite">
      <pre wrap="">On Sat, Jun 07, 2014 at 08:04:09PM -0400, Elric wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Hi,

I came across this article: <a class="moz-txt-link-freetext" href="http://unriskinsight.blogspot.co.at/2014/06/fast-functional-goats-lions-and-wolves.html">http://unriskinsight.blogspot.co.at/2014/06/fast-functional-goats-lions-and-wolves.html</a>
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.

</pre>
      </blockquote>
      <pre wrap="">
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






</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Beginners mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://www.haskell.org/mailman/listinfo/beginners">http://www.haskell.org/mailman/listinfo/beginners</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>