johncpw wrote:
I have try to simulate 'function' by using boardcast, but can I simulate recurrion? I remeber I can define function and recurrion in traditional LOGO.
I think you are talking about "recursion". Take a look at Jens work
http://scratch.mit.edu/users/jens
he has done a lot of work with recursion. He has even made his own version of Scratch that supports recursion directly.
You can simulate recursion using a List as a stack...here is an example
http://scratch.mit.edu/projects/Paddle2SeeFixIt/482887
The tree is drawn by repeatedly calling the Draw One Branch routine.
Offline
Hi coolstuff.
wikipedia wrote:
Recursion
If you still don't get it, see: "Recursion".
Recursion usually refers to a function calling itself, i.e. in order to navigate a tree-node or determine a number's factorial.
Logo is a wonderful programming language, and in many ways Scratch's predecessor.
Offline
coolstuff wrote:
Excuse me for asking, but what exactly is recursion? The word rings a bell, but I can't see the bell.
Also, what is Logo?
Well, the definition is here
http://en.wikipedia.org/wiki/Recursive_definition
but it's pretty hard to understand. Maybe an example would help: factorials of numbers. To get the factorial of a number you multiply that number by all the positive integers less than that number. So the factorial of 6 = 6*5*4*3*2*1 = 720. The symbol for factorial is the exclamation mark so another way to say the same thing is
6! = 6*5*4*3*2*1 = 720
But if we look at that more closely, we can see that it is the same as 6 times the factorial of 5. So we can write
6! = 6 * 5!
Or, for any positive integer number N
if N = 1 then N! = 1
If N > 1 then N! = N * (N-1)!
So this is a recursive definition of the factorial operation...since it includes itself in the definition. Kind of weird, huh? But you could use this definition (and many people do) to write a recursive program that calculates factorial numbers.
Offline
Jens wrote:
Hi coolstuff.
wikipedia wrote:
Recursion
If you still don't get it, see: "Recursion".
![]()
Recursion usually refers to a function calling itself, i.e. in order to navigate a tree-node or determine a number's factorial.
Logo is a wonderful programming language, and in many ways Scratch's predecessor.
Paddle2See wrote:
Well, the definition is here
http://en.wikipedia.org/wiki/Recursive_definition
but it's pretty hard to understand. Maybe an example would help: factorials of numbers. To get the factorial of a number you multiply that number by all the positive integers less than that number. So the factorial of 6 = 6*5*4*3*2*1 = 720. The symbol for factorial is the exclamation mark so another way to say the same thing is
6! = 6*5*4*3*2*1 = 720
But if we look at that more closely, we can see that it is the same as 6 times the factorial of 5. So we can write
6! = 6 * 5!
Or, for any positive integer number N
if N = 1 then N! = 1
If N > 1 then N! = N * (N-1)!
So this is a recursive definition of the factorial operation...since it includes itself in the definition. Kind of weird, huh? But you could use this definition (and many people do) to write a recursive program that calculates factorial numbers.
Thanks!
Offline
*stares at what Paddle2See wrote* uhhhhhhhhhhhh... I think I get it. *n*
Offline