Um ... To the other people giving
hints: Don't forget that in the sequence *of lines in the
program* you have to state the base case(s) *first*, certainly in
Haskell, which goes through the lines in order, until it finds a
match.
That's what I meant when I said "first do the base case(s), then
the rest": first *in the program order*, if not necessarily in
the conceptual structure. So for the depth-first binary tree
which Joel Neely pointed out, *first* you must deal with the base
case that the node being looked at is actually a leaf; *only then*
can you deal with the fact that in general the algorithm has the
structure <process left descendants><process this
node><process right descendants>.
So if you try <move stack off of bottom><move
bottom><place stack on bottom>, the first part will
either enter an endless loop or will generate an error, because it
doesn't have a base case. (No pun on "base" intended.)
On 2/17/15 4:05 AM, Joel Neely wrote:
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners