From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3e08c98d7ce85399 X-Google-Attributes: gid103376,public From: bourguet@my-deja.com Subject: Re: Eight Queens problem (was Re: Kindness) Date: 1999/09/08 Message-ID: <7r50tj$sp3$1@nnrp1.deja.com>#1/1 X-Deja-AN: 522413799 References: <37CC6844.AB898EEE@rational.com> <37CE93CD.799A225A@pwfl.com> <37CF0FE0.2B299477@acenet.com.au> <37CFF7DC.CFF9717C@pwfl.com> <1999Sep3.125818.1@eisner> <37D02CC0.BEF1BC69@mitre.org> <7r1c4c$9an$1@nnrp1.deja.com> <7r2fc6$1sc$1@nnrp1.deja.com> <7r4edb$gg2$1@nnrp1.deja.com> X-Http-Proxy: NetCache@sj-netcache: Version DEMO_9T4, 1.0 x36.deja.com:80 (Squid/1.1.22) for client 158.140.3.201 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Wed Sep 08 06:49:25 1999 GMT X-MyDeja-Info: XMYDJUIDbourguet Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (X11; I; SunOS 5.5.1 sun4u) Date: 1999-09-08T00:00:00+00:00 List-Id: In article <7r4edb$gg2$1@nnrp1.deja.com>, Robert Dewar 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.