<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Mike Meyer schreef op 19-2-2015 om
      8:25:<br>
    </div>
    <blockquote
cite="mid:CAD=7U2BL9Oj5XKZZb2UhdrBqVfRv+wM4WdK-wvjNFOTD+1E88Q@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Thu, Feb 19, 2015 at 1:11 AM,
            Roelof Wobben <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:r.wobben@home.nl" target="_blank">r.wobben@home.nl</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000">
                <div>I think I found the answer by some trail and error,<br>
                  <br>
                  hanoi 1 start _ end = [ (start, end)]<br>
                  hanoi n start temp end = hanoi (n-1) start end temp ++
                  [(start, end)] ++ hanoi (n-1) temp start end<br>
                  <br>
                  main = print $ hanoi 3 'a' 'b' 'c'<br>
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>I mentioned earlier that using "hanoi 1 start temp end"
              instead of "[(start, end)]" made things read a bit better
              to me. I figured out why. It isolates the final
              representation of a "move" to the base case only. So if
              you make that change, you could then write your base case
              as:</div>
            <div><br>
            </div>
            <div>hanoi 1 start _ end = "move 1 disk from " ++ start ++ "
              to " ++ end ++ ".\n"  </div>
            <div><br>
            </div>
            <div>and the other case still works correctly if you used
              the "hanoi 1" version. You'll want to change "print" to
              "putStr" in main, but it will now print the list of moves
              in English instead of Haskell.</div>
          </div>
        </div>
      </div>
      <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://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
    </blockquote>
    <br>
    Thanks, <br>
    <br>
    1 remark.<br>
    <br>
    You have to do this hanoi 1 start _ end = "move 1 disk from " ++
    [start] ++ " to " ++ [end] ++ ".\n"  <br>
    because in your code you get this error message : <br>
    <br>
    <span class="ssh-terminal-size-tester"></span>
    <textarea style="position: fixed; z-index: 100; border: 0px none;
      width: 120px; height: 120px; padding: 0px; opacity: 0;"
      tabindex="0" class="clipboard"></textarea><textarea rows="1"
      class="terminal-input"></textarea>
    <div>*Main> main                                                                                                                                                                                                          </div>
    <div>[('a','c'),('a','b'),('c','b'),('a','c'),('b','a'),('b','c'),('a','c')]                                                                                                                                              </div>
    <div>*Main> :l hanoi                                                                                                                                                                                                      </div>
    <div>[1 of 1] Compiling Main             ( hanoi.hs, interpreted )                                                                                                                                                        </div>
    <div>                                                                                                                                                                                                                     </div>
    <div>hanoi.hs:4:24:                                                                                                                                                                                                       </div>
    <div>    Couldn't match expected type ‘[Char]’ with actual type ‘Char’                                                                                                                                                    </div>
    <div>    In the second argument of ‘hanoi’, namely ‘'a'’                                                                                                                                                                  </div>
    <div>    In the second argument of ‘($)’, namely ‘hanoi 3 'a' 'b' 'c'’                                                                                                                                                    </div>
    <div>    In the expression: print $ hanoi 3 'a' 'b' 'c'                                                                                                                                                                   </div>
    <div>                                                                                                                                                                                                                     </div>
    <div>hanoi.hs:4:28:                                                                                                                                                                                                       </div>
    <div>    Couldn't match expected type ‘[Char]’ with actual type ‘Char’                                                                                                                                                    </div>
    <div>    In the third argument of ‘hanoi’, namely ‘'b'’                                                                                                                                                                   </div>
    <div>    In the second argument of ‘($)’, namely ‘hanoi 3 'a' 'b' 'c'’                                                                                                                                                    </div>
    <div>    In the expression: print $ hanoi 3 'a' 'b' 'c'                                                                                                                                                                   </div>
    <div>                                                                                                                                                                                                                     </div>
    <div>hanoi.hs:4:32:                                                                                                                                                                                                       </div>
    <div>    Couldn't match expected type ‘[Char]’ with actual type ‘Char’                                                                                                                                                    </div>
    <div>    In the fourth argument of ‘hanoi’, namely ‘'c'’                                                                                                                                                                  </div>
    <div>    In the second argument of ‘($)’, namely ‘hanoi 3 'a' 'b' 'c'’                                                                                                                                                    </div>
    <div>    In the expression: print $ hanoi 3 'a' 'b' 'c'                                                                                                                                                                   </div>
    <div>Failed, modules loaded: none.                                                                                                                                                                                        </div>
    <div>Prelude> :l hanoi                                                                                                                                                                                                    </div>
    <div>[1 of 1] Compiling Main             ( hanoi.hs, interpreted )                                                                                                                                                        </div>
    <div>                                                                                                                                                                                                                     </div>
    <div>hanoi.hs:4:25:                                                                                                                                                                                                       </div>
    <div>    Couldn't match expected type ‘[Char]’ with actual type ‘Char’                                                                                                                                                    </div>
    <div>    In the second argument of ‘hanoi’, namely ‘'a'’                                                                                                                                                                  </div>
    <div>    In the second argument of ‘($)’, namely ‘hanoi 3 'a' 'b' 'c'’                                                                                                                                                    </div>
    <div>    In the expression: putStr $ hanoi 3 'a' 'b' 'c'                                                                                                                                                                  </div>
    <div>                                                                                                                                                                                                                     </div>
    <div>hanoi.hs:4:29:                                                                                                                                                                                                       </div>
    <div>    Couldn't match expected type ‘[Char]’ with actual type ‘Char’                                                                                                                                                    </div>
    <div>    In the third argument of ‘hanoi’, namely ‘'b'’                                                                                                                                                                   </div>
    <div>    In the second argument of ‘($)’, namely ‘hanoi 3 'a' 'b' 'c'’                                                                                                                                                    </div>
    <div>    In the expression: putStr $ hanoi 3 'a' 'b' 'c'                                                                                                                                                                  </div>
    <div>                                                                                                                                                                                                                     </div>
    <div>hanoi.hs:4:33:                                                                                                                                                                                                       </div>
    <div>    Couldn't match expected type ‘[Char]’ with actual type ‘Char’                                                                                                                                                    </div>
    <div>    In the fourth argument of ‘hanoi’, namely ‘'c'’                                                                                                                                                                  </div>
    <div>    In the second argument of ‘($)’, namely ‘hanoi 3 'a' 'b' 'c'’                                                                                                                                                    </div>
        In the expression: putStr $ hanoi 3 'a' 'b' 'c'                <br>
    <br>
    Now I  have to figure out  how this works before I can work on the
    optional exercise hanoi with  4 pegs. <br>
    <br>
    Roelof<br>
    <br>
  </body>
</html>