 | | RE: cursion (was RE: Would-be hacker queries.)
|
|
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 (...) (28 years ago, 11-May-99, to lugnet.robotics)
|
| |
 | | A recursion question/test...
|
|
Hi, With all the discussion on understanding recursion and such for programmers I thought I'd share a little problem I find enlightening.... Describe as simple a recursive algorithm as possible for summing the first n numbers. ___...___ Three step (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: A recursion question/test...
|
|
(...) d'oh. my ($n)=@ARGV; my $result=$n; $result += $n while($n--); print $result."\n"; What a difference a compile makes... but it's still not very recursive. I'll be interested in seeing your answer. Aloha, JR - - - - - - - - - - JR Conlin (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: A recursion question/test...
|
|
Jim Choate poses the problem: (...) What other than sum(n) = n + sum(n-1) (with proper termination conditions, of course - sum(1) = 1). Ralph deal@kzoo.edu -- Did you check the web site first?: (URL) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | You know, all this computer science talk doesn't really belong here.
|
|
Try lugnet.off-topic.geek. :) (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: Scheme (fwd)
|
|
On Tue, 11 May 1999, Jim Choate wrote: . . . (...) More details: In 1966, work began on LOGO at Bolt, Beranek, & Newman. The team was headed by Wally Fuerzeig and included Seymour Papert who later wrote the text which popularized LOGO: MindStorms. (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: Fishing for a tasty linkage/gearing/robotic building thread...
|
|
Me too !! Kipling Morris wrote in message ... (...) against (...) I (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: A recursion question/test... (correction)
|
|
Whoops! I typed the last two lines with the two aggregate operators interchanged! Obviously they should have read FUNCTION sum(n: natural): natural = SUM [0..n] FUNCTION fac(n: natural): natural = PRODUCT [1..n] Malcolm -- Did you check the web site (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: A recursion question/test...
|
|
It should be pointed out that the problem of summing the first n natural numbers is isomorphic to that of finding the factorial of n. Compare these two functions FUNCTION sum(n: natural): natural = IF n = 0 THEN 0 ELSE n + sum(n - 1) FUNCTION fac(n: (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | mindstorms - motors and stuff
|
|
Just wondering - I've seen people hook up 2 motors to a port - how many is it safe to use? How much current can this thing supply? Can it drive the old-style 9V motors? (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: Would-be hacker queries. (fwd)
|
|
(...) That is a rather limited version of recursion, which does not, in general, require f(n-1) to evaluate f(n). What you have described is actually (a subset of) partial recursion, which is provably incomplete (i.e. cannot implement some (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: A recursion question/test...
|
|
(...) int sum(int n) { return n*(n-1)/2; } A degenerate recursive algorithm, of course. Cheers, Ben. -- (URL) grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: A recursion question/test...
|
|
It should be pointed out that the problem of summing the first n natural numbers is isomorphic to that of finding the factorial of n. Compare these two functions FUNCTION sum(n: natural): natural = IF n = 0 THEN 0 ELSE n + sum(n - 1) FUNCTION fac(n: (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: Scheme (fwd)
|
|
----- Forwarded message from Ralph M. Deal ----- Date: Wed, 12 May 1999 01:52:41 -0400 (EDT) From: "Ralph M. Deal" <deal@kzoo.edu> Subject: Re: Scheme (fwd) (...) Can you furnish a source for MSWLogo? On what platforms does it run? ----- End of (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: Fishing for a tasty linkage/gearing/robotic building thread...
|
|
(...) I totally agree about needing a new building thread. It seems like there is a lot of effort for software in a box with only three inputs and three outputs. Whatever turns you on I suppose. We all get enjoyment from this product in different (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: Fishing for a tasty linkage/gearing/robotic building thread...
|
|
(...) I am working on a LEGO color copier machine. I've been fooling with it for a couple of months now (not so much due to difficulty as to lack of free time). Physically, my copier is basically an XY plotter with four interchangable colored pens. (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: Fishing for a tasty linkage/gearing/robotic building thread...
|
|
Michael, If you only need to make right angle changes of direction how about a design where the robot does not turn. You could have one set of axles for forward/backward with 1 motor driving both sides so you go straight. Then to change direction a (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: Fishing for a tasty linkage/gearing/robotic building thread...
|
|
I would try using one motor to drive and a ratchet on one of the wheels. Then when you go in reverse, you turn. Time the motor power setting and turn rate until you get a good 90 degree turn. The other way would be to use some kind of line (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Re: Fishing for a tasty linkage/gearing/robotic building thread...
|
|
(...) I was toying around with something like this. A foot like thing would come down, lift the whole vehicle up off the ground, then turn it right or left 90 degrees (maybe even a variable angle), and set it back down. It does look like a three (...) (28 years ago, 12-May-99, to lugnet.robotics)
|
| |
 | | Light sensor help??Newbie!!!
|
|
Hi All! I have a problem with the light sensor using the included software. (Don't groan all you advanced programmers, please ;-> ) But anyway, the manual states and I quote" trigger the stack when the FIRST of TWO consecutive readings falls outside (...) (28 years ago, 12-May-99, to lugnet.robotics)
|