comp.lang.ada
 help / color / mirror / Atom feed
From: bourguet@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: <7r50tj$sp3$1@nnrp1.deja.com> (raw)
In-Reply-To: 7r4edb$gg2$1@nnrp1.deja.com

In article <7r4edb$gg2$1@nnrp1.deja.com>,
  Robert Dewar <robert_dewar@my-deja.com> wrote:
> 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.

Is the classical way of writing the factorial

function fact(n : natural) return natural is
begin
   if n = 0 then
      return 1;
   else
      return n*fact(n-1);
   end if;
end fact;

tail recursive? There is a multiplication to be executed after the
return. Writing a tail recursive version is a little more complicated
and is an interesting thing to do. But obviously you are then even
nearer of the iterated version.

> Here is the example I always use, with a little driver:
[recursive version of print_int]
Indeed this is more interesting than factorial for introducing
recursion.

-- Jean-Marc


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 Robert Dewar
1999-09-03  0:00       ` Kindness Aidan Skinner
1999-09-03  0:00         ` Kindness Larry Kilgallen
1999-09-04  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-06  0:00       ` Kindness Geoff Bull
1999-09-05  0:00         ` Kindness Aidan Skinner
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
1999-09-08  0:00                     ` bourguet [this message]
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-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 Mark Lundquist
1999-09-10  0:00       ` Kindness Robert Dewar
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