comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: Eight Queens problem (was Re: Kindness)
Date: 1999/09/08
Date: 1999-09-08T00:00:00+00:00	[thread overview]
Message-ID: <7r4edb$gg2$1@nnrp1.deja.com> (raw)
In-Reply-To: 7r2fc6$1sc$1@nnrp1.deja.com

In article <7r2fc6$1sc$1@nnrp1.deja.com>,
  bourguet@my-deja.com wrote:
> Do you want to say it is the canonical example of use or it is
an as
> good example: there is another way to solve the problem which
usually
> come first to mind?

Nothing so complicated, just that, as factorial is typically
used in a text book to illustrate recursion, 8Q is used to
illustrate backtracking.

I agree that simple tail recursion is a horrible example for
motivating recursion. Here is the example I always use, with
a little driver:

with Text_IO; use Text_IO;
procedure p is
   procedure Print_Int (I : Natural) is
   begin
      if I >= 10 then
         Print_Int (I / 10);
      end if;
      Put (Character'Val (Character'Pos ('0') + I mod 10));
   end Print_Int;
begin
   Print_Int (12435);
end;

The nice thing about this is that it does simply something
which is annoyingly fiddly to do iteratively. In particular,
you have to worry about the maximum number of digits which
simply does not arise. The point is made even more strongly
in a language which does not have nasty artificial limits on
the size of integers as in C or Ada or Java :-)

Robert Dewar


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




  reply	other threads:[~1999-09-08  0:00 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-31  0:00 Kindness Mark Lundquist
1999-09-02  0:00 ` Kindness Marin David Condic
1999-09-03  0:00   ` Kindness Geoff Bull
1999-09-03  0:00     ` Kindness Marin David Condic
1999-09-03  0:00       ` Kindness Larry Kilgallen
1999-09-03  0:00         ` Kindness Robert I. Eachus
1999-09-04  0:00           ` Eight Queens problem (was Re: Kindness) Daryle Walker
1999-09-05  0:00             ` Robert Dewar
1999-09-14  0:00               ` Robert I. Eachus
1999-09-06  0:00             ` Vladimir Olensky
1999-09-06  0:00               ` Robert Dewar
1999-09-07  0:00                 ` bourguet
1999-09-08  0:00                   ` Robert Dewar [this message]
1999-09-08  0:00                     ` bourguet
1999-09-08  0:00                       ` Robert Dewar
1999-09-08  0:00                         ` Ted Dennison
1999-09-03  0:00         ` Kindness tmoran
1999-09-03  0:00           ` Kindness Marin David Condic
     [not found]         ` <37D55622.69B27515@rational.com>
1999-09-07  0:00           ` Homework (was Re: Kindness) Larry Kilgallen
1999-09-08  0:00             ` Ted Dennison
1999-09-08  0:00           ` Homework Mark Lundquist
1999-09-03  0:00     ` Kindness Robert Dewar
1999-09-03  0:00       ` Kindness Aidan Skinner
1999-09-03  0:00         ` Kindness Marin David Condic
1999-09-06  0:00           ` Kindness Bill Findlay
1999-09-06  0:00             ` Kindness Robert Dewar
1999-09-07  0:00             ` Kindness Marin David Condic
1999-09-07  0:00               ` Kindness Bill Findlay
1999-09-03  0:00         ` Kindness Larry Kilgallen
1999-09-04  0:00           ` Kindness Aidan Skinner
1999-09-06  0:00       ` Kindness Geoff Bull
1999-09-05  0:00         ` Kindness Aidan Skinner
1999-09-02  0:00 ` Kindness Jerry Petrey
1999-09-02  0:00   ` Kindness Nick Roberts
1999-09-02  0:00 ` Kindness Larry Kilgallen
1999-09-03  0:00   ` Kindness Robert Dewar
1999-09-03  0:00     ` Kindness Andy Askey
1999-09-05  0:00       ` Kindness Robert Dewar
1999-09-07  0:00         ` Kindness Andy Askey
1999-09-07  0:00           ` Kindness Bill Findlay
1999-09-03  0:00 ` Kindness Matthew Heaney
1999-09-09  0:00   ` Kindness James William Zuercher
1999-09-10  0:00     ` Kindness Robert Dewar
1999-09-10  0:00     ` Kindness Mark Lundquist
1999-09-10  0:00       ` Kindness Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox