<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">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>
<br>
Roelof<br>
<br>
<br>
Mike Meyer schreef op 19-2-2015 om 2:29:<br>
</div>
<blockquote
cite="mid:CAD=7U2CQoemwY_O4c+M26oTfT3wiLRC3TX2RViG9tYgbVVGaNQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Wed, Feb 18, 2015 at 7:16 PM,
Dudley Brooks <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:dbrooks@runforyourlife.org" target="_blank">dbrooks@runforyourlife.org</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>Hmm. Well, I'd say that that's a feature of,
specifically, Haskell's pattern-matching strategy and
list-description syntax, rather than of recursion in
general or the structure of this particular problem.
In other languages with recursion you might have no
choice except to start with the base case, even for
this problem, or else you'd get the same kind of error
you mention below (depending on the language). I
think it's good when you're *learning* recursion to
always start with the base case(s).<br>
</div>
</div>
</blockquote>
</div>
</div>
<div class="gmail_extra">I disagree that this is a
Haskell-specific feature. Any else-if like structure will have
this property, no matter what language it's in. That Haskell
provides a syntax as part of the function declaration is
special, but that doesn't let you avoid the else-if construct
when the problem requires it.</div>
<div class="gmail_extra"><br>
</div>
<div class="gmail_extra">It may be my fondness for proof by
induction, but I think doing the base case first is a good
idea for another reason. The code for the recursive cases
assumes that you can correctly handle all the "smaller" cases.
If that's wrong because some assumption about the base case
turns out to be false when you actually write it, then you
have to rewrite the recursive cases for the correct base case.
So it's better to make sure your base case is going to work
before you start writing the code that's going to use it.</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>
</body>
</html>