From: Louis Krupp on
Joe Zitzelberger wrote:
[snip}
> For production code, you would write this as a loop. But this is a
> great example to help students understand how recursion actually works.
>
> Simple parameters, easy to grasp output....factorial() is made to teach
> recursion.
>
> Can you think of a better (e.g. easier to understand) example to
> introduce the concept?

If I had ten minutes to introduce COBOL to people who had never seen it
before, I'd stick with iteration.

Louis
From: Michael Wojcik on

In article <11sf29snp1as55c(a)corp.supernews.com>, Louis Krupp <lkrupp(a)pssw.nospam.com.invalid> writes:
> Joe Zitzelberger wrote:
> [snip}
> > For production code, you would write this as a loop. But this is a
> > great example to help students understand how recursion actually works.
> >
> > Can you think of a better (e.g. easier to understand) example to
> > introduce the concept?

Certainly some of the other classics, such as tree traversal, aren't
an easy fit for traditional COBOL. It's not hard to implement binary
trees in COBOL, with or without pointers, but it's atypical.

Recursive list reversal is pretty clean in COBOL, but the algorithm
is a little more complex than factorial.

> If I had ten minutes to introduce COBOL to people who had never seen it
> before, I'd stick with iteration.

Sure, but teaching COBOL using recursion is a rather different task
from teaching recursion using COBOL.

--
Michael Wojcik michael.wojcik(a)microfocus.com

Unfortunately, as a software professional, tradition requires me to spend New
Years Eve drinking alone, playing video games and sobbing uncontrollably.
-- Peter Johnson
From: Peter Lacey on
Joe Zitzelberger wrote:

<snip>

> For production code, you would write this as a loop. But this is a
> great example to help students understand how recursion actually works.
>
> Simple parameters, easy to grasp output....factorial() is made to teach
> recursion.
>
> Can you think of a better (e.g. easier to understand) example to
> introduce the concept?

To be perfectly frank, I wouldn't mention recursion in a class teaching
Cobol, except in passing as something to be studied as an advanced
topic. In my own (woe is me, long ago) student days, we had topics such
as air-traffic control, programs that could learn, and recursion: all a
waste of time AT THE TIME. I won't dispute that there are a few
students capable of taking such a concept at a tender age and making
much of it but in such a case the instructor's job would be to make
arrangements for the gifted student to surge ahead, not to inflict the
topic on the whole class. Certainly you want to give the group
challenges, to stretch their minds and make them think, but there are
gazillions of more fruitful assignments: the standard file update, both
master and transaction files being sequential, for instance.

To answer your question, I can't think of an easier way to introduce
recursion. But I would be very careful to state that recursion is
probably not the best way to implement it in the real world. Remember
TPB, who'll have to maintain the program!

PL
From: Robert Jones on

Has anyone yet suggested that you could provide examples of how to do
it both ways, which would have the advantage of explaining how
recursion is achieved while also illustrating the advantages and
disadvantages of each approach according to circumstance.

Robert

From: Howard Brazee on
On Fri, 13 Jan 2006 13:08:25 -0600, Peter Lacey <lacey(a)mts.net> wrote:

>To be perfectly frank, I wouldn't mention recursion in a class teaching
>Cobol, except in passing as something to be studied as an advanced
>topic.

My work has a Thursday afternoon class in JBuilder. Some of the
students already use Java, and skip classes in Java, but most of us
have not used Java professionally.

We won't end up with good Java knowledge - we will end up with the
Java knowledge needed for our work - which will be mainly
communicating between databases and Web services.

So we have a list of subsets that we must know, and another list of
stuff which we can safely ignore for now.

Students often have a hard time narrowing down what they need to
study, and waste time studying the wrong stuff early. Once we learn
the language, I agree most anything is worth learning. But lots of
people never do learn little used features and have long careers.

Getting down how the language works in real life practical examples
makes learning the language easy. Start using the language the way it
was designed to be used, practice it, learn it - and then expand on
its capabilities.
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10
Prev: Data Representation in COBOL
Next: xml acucobol