To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 5011
5010  |  5012
Subject: 
RE: cursion (was RE: Would-be hacker queries.)
Newsgroups: 
lugnet.robotics
Date: 
Tue, 11 May 1999 15:49:07 GMT
Original-From: 
Stalker-Wilde, Graham <graham.stalker-wilde@csfb.SPAMLESScom>
Viewed: 
721 times
  
I hate to be pedantic, but what you're describing is functional composition.
The key to recursion is that the function calls itself.
e.g.

int factorial(int n) // assumes n > 0
{
    if (n > 1)
    return n * factorial( n - 1);    // the recursive call, this is
what chews up your stack
   else
   return 1;   // the terminal condition - there has to be some way
the function stops calling itself
}

Recursion is expressively powerful, elegant, concise, and often horribly
inefficient.

I agree that the examples often given are impractical - this isn't really
how one would code factorials or fibonacci numbers - still, it gets the idea
across, and it is a cool idea.

(and you know, I don't _really_ hate being pedantic.)

-graham

"To iterate is human; to recurse, divine"



-----Original Message-----
From: JR Conlin [SMTP:jrconlin@email.com]
Sent: Tuesday, May 11, 1999 10:46 AM
To: 'lego-robotics@crynwr.com'
Subject: RE: Would-be hacker queries.

At 05:44 PM 5/10/99 -0400, Blake Winton wrote:
>
>> Eric Lind wrote:
>> > recursion - the process of one function calling itself to solve
a
problem.
>
>You might want to add the recursive part of this example
>(namely 6! = 6*(5!), and 5! = 5*(4!), and so on,

You know, I have never really liked the factorial example of
recursion.
Honestly, how many times have you really needed to generate a
factorial in
general experience?

I feel a better example is building stuff with LEGO. In this case,
you are
the function and the LEGO is the data.

The basic function you perform is sticking blocks together. So to
build a
rocket ship, you first need to attach the body to the engine. To
build the
engine you need to attach the intake to the exhaust, and so on. As
you
progress, you may be generating very complex items, but you are
still
performing the same basic action, attaching one block to another.



Aloha,
JR
- - - - - - - - - -
JR Conlin                  jrconlin@email.com
Techno-Athiest yahooPage: jrconlin
                           <http://home.earthlink.net/~jrconlin>
--
Did you check the web site first?:
http://www.crynwr.com/lego-robotics
--
Did you check the web site first?: http://www.crynwr.com/lego-robotics



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR