Re: Recursive functions
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Wed, 04 Apr 2007 16:58:26 -0700
army1987@xxxxxxxx writes:
Keith Thompson ha scritto:
In real-world C code, I agree. <OT>In Lisp-like languages, it mightBut it *is* useful to know how to print a message to stdin from within
be perfectly appropriate.</OT>
But homework assignments are not real-world code; consider how easily
we can tell the difference when people post here asking for help. The
canonical first program is "Hello, world". That's not something for
which there's any real-world requirement.
a real-world C program (it is done all time)...
I assume you mean stdout, not stdin. But that's not the main point of
the "hello, world" program. It's certainly one thing a student will
learn from it, but the main point is to learn how to write, compile,
and execute a program.
Similarly, problems that actually require recursion tend to be more...whereas it is *totally* *useless* to know how to recursively
complex than might be appropriate for a beginner, but we *can* teach
the elements of recursion using artificially simple example, like
computing the length of a string. It might be appropriate to mention
in passing that recursion really isn't the best solution (in fact, a
call to the strlen() function is) -- and for all we know, the OP's
instructor might have mentioned that.
implement an algorithm which is 1) much, much better implemented
iteratively, and 2) already implemented by the standard library.
The point is not to learn how to compute the length of a string. The
point is to learn about recursion. Introducing the concept of
recursion via a simple task allows the student to learn about the
concept without a lot of extraneous details getting in the way.
How did you first learn about recursion?
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- Follow-Ups:
- Re: Recursive functions
- From: Army1987
- Re: Recursive functions
- From: Richard Heathfield
- Re: Recursive functions
- References:
- Recursive functions
- From: Harry
- Re: Recursive functions
- From: Bill Pursell
- Re: Recursive functions
- From: Harald van Dijk
- Re: Recursive functions
- From: Bill Pursell
- Re: Recursive functions
- From: Lauri Alanko
- Re: Recursive functions
- From: Bill Pursell
- Re: Recursive functions
- From: Keith Thompson
- Re: Recursive functions
- From: army1987
- Recursive functions
- Prev by Date: Re: How to find string contains a numeric value
- Next by Date: Re: Can you do this? (bit ops)
- Previous by thread: Re: Recursive functions
- Next by thread: Re: Recursive functions
- Index(es):
Relevant Pages
|