This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-04-29 04:42:47

johncpw
Scratcher
Registered: 2009-04-29
Posts: 2

Can Scratch supports recurrion?

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.

Offline

 

#2 2009-04-29 05:27:27

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Can Scratch supports recurrion?

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.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#3 2009-04-29 16:26:37

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Can Scratch supports recurrion?

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?

Offline

 

#4 2009-04-29 17:10:29

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Can Scratch supports recurrion?

Hi coolstuff.

wikipedia wrote:

Recursion
        If you still don't get it, see: "Recursion".

smile
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.


Jens Mönig

Offline

 

#5 2009-04-29 17:48:35

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Can Scratch supports recurrion?

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.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#6 2009-04-29 18:00:40

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Can Scratch supports recurrion?

Jens wrote:

Hi coolstuff.

wikipedia wrote:

Recursion
        If you still don't get it, see: "Recursion".

smile
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

 

#7 2009-04-30 03:45:54

johncpw
Scratcher
Registered: 2009-04-29
Posts: 2

Re: Can Scratch supports recurrion?

Yes, I have mispelled the word. Thank you for your help.

Offline

 

#8 2009-04-30 05:14:42

MyRedNeptune
Community Moderator
Registered: 2007-05-07
Posts: 1000+

Re: Can Scratch supports recurrion?

*stares at what Paddle2See wrote* uhhhhhhhhhhhh... I think I get it. *n*


http://i52.tinypic.com/5es7t0.png I know what you're thinking! "Neptune! Get rid of those filthy advertisements and give us back the Zarathustra siggy, you horrible person!" Well, don't worry about it, the Zara siggy will be back soon, new and improved! ^^ Meanwhile, just do what the sig tells you to. >.>

Offline

 

Board footer