View Full Version : recursion, HELP PLEASE....
miogi
11-19-2006, 04:39 PM
hello, I am kinda blind when it comes to programming. I am taking a computer course that has programming in it and I am having great difficult in understanding lots of elements in this Alice Program. We have a big asignment on trying to catch a butterfly with a net and I have to use Recursion. I have tried to understand chapter 8, but feel it is not coming easy.. I was wondering if you could point me in the right direction such as give me a few example worlds or any info I could use to get me started with this. I have to hand my code in very soon a couple of days and I am lost! I am not asking for you to give me the answers, just a way that I could understand it better. a few simple example worlds showing recursion with calling a method and maybe calling a parameter.. Please help if you can...
Lost with Alice.... Miogi
DrJim
11-19-2006, 05:09 PM
Just remember the Geek Dictionary definition:
"Recursion: See Recursion" :)
The thread http://www.alice.org/community/showthread.php?t=484
may help - it has an example of recursive code I did.
Also try looking up recursion in Wiki - it has a prettly good section.
Shadow Sovereign
11-19-2006, 06:20 PM
Just remember the Geek Dictionary definition:
"Recursion: See Recursion" :)
I knew there was a Nerd Dictionary, but a Geek Dictionary? Now that's big! :p
miogi
11-20-2006, 03:06 AM
hey, just wanted to say thanks, I have actually looked at that file regarding recursion, I dl'd it before, but still trying to understand how to code such a thing and where to start. With everything else going on at School, it is hard to just sit down and give Alice another 15-18 hours of time .. lol, sometimes the biggest thing is to just get started.. My instructor went over it slightly in class, but I feel he went to fast for my brain. He put in some recursion with numbers and generated some hugh number(still dont understand what he did, lol) But anyhow, A code that is done such as Fibonacci is hard to understand. If someone has a small code with recursion that I could look at, just a sample of how to start with it, or even how to start with my butterfly one, that would be great.. Peace to all...
Miogi
DrJim
11-20-2006, 06:54 PM
You're making it way too hard just because it sounds that way. :p
I suggest you look at the attached code and run the world a couple of times. Then delete the "if block" and reenter it yourself - you will get a warning from Alice that you are about to make a recursive call, that is, the method is calling itself. Say you know what you are doing (even if you don't :D ) and run the world again. If you did it right, :) you should get the same result. If you don't, :confused: compare your code back to the original.
Note that you have to have the "if test" there or it will run forever (or at least until your computer wears out or you pull the plug).
a002329
09-18-2010, 02:36 AM
Create a sea world with a boat and an island. Position the island some distance
away from the boat, as shown in Figure 8-26. Write a method named sailTo,
which has an Object parameter. The method should cause the boat to move one
meter toward the object and then recursively call itself until the boat has reached
the object. Test the method by calling it and passing the island as the argument
bmarh
09-18-2010, 09:30 AM
My boat do not stop at the island