Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Create a 12 page essay paper that discusses Logo Programming Language.Download file to see previous pages... Recursion is an alternative to REPEAT command. In general, Recursion is delineating as the

Create a 12 page essay paper that discusses Logo Programming Language.

Download file to see previous pages...

Recursion is an alternative to REPEAT command. In general, Recursion is delineating as the process under which a function is defined in such a way that the function being defined is applied within its own definition. The term can be explained by taking a very simple example. Suppose, when the surfaces of two mirrors are placed parallel with each other the nested images that occur are a form of recursion. The great advantage of recursion is that an infinite set of possible sentences, designs or other data can be defined, parsed or produced by a finite computer program. Logo allows the recursion where a procedure calls itself.

The secret of recursive programming is the same as a secret of problem solving in general that is to reduce a big problem to a smaller problem. Now to make the above program more general and flexible, we can use recursive pattern in the following way.

In the above example, we use the variable word instead of word "hello" and a general relationship is defined that will transform hello into hell. That relationship is established using the keyword butlast.

The above procedure becomes more meaningful using the stop rule. To implement stop rule user must answer, "What's the smallest case we want the program to handle" The answer is that for a single-letter word the downup should just print the word once. In other words, for a single-letter word, downup should carry out its first instruction and then stop. So the stop rule goes after that first instruction, and it stops if the input has only one letter:

to downup :word

print :word

if equalp count :word 1 [stop]

downup butlast :word

print :word

end

Another application of recursion is to draw square spiral. The following is the code to draw square spiral.

TO SQSPI :L

IF :L &gt. 150 [STOP]

FD :L RT 90

SQSPI :L + 5

END

Suppose we give a command SQSPL 100

That means he should write 100 on a piece of paper and put it in his :L pocket.

IF (:L &gt. 150) [STOP]

This is "the stop condition". The turtle looks in the front of his :L pocket and sees 150. He asks himself if 100 &gt.150. If it is, then he will STOP. It is not, so he carries on.

Now "the action" is performed. First FD :L, so the turtle walks FD 100. Then RT 90. Now he has drawn this:

And then "the call":

SQSPI :L + 5

How can we tell the turtle to do SPIRAL again before he has finished with the first The turtle does not care. He just says I will finish the first SPIRAL later. He knows that the latest paper he put in his :L pocket is the only thing he needs to keep track of now. He saves the rest for later.

: L + 5 is 100+5. That is 105. Therefore, the turtle now puts a paper with 105 in front of the other paper in his pocket. The next thing he sees is this:

IF (:L &gt.150) [STOP]

This is "the stop condition" again. He looks at the paper he just put in his :L pocket. Its 105, so it is smaller than 150. Therefore he does not stop.

Then there's "the action". He sees FD :L. So he walks FD 105. Then RT 90. Now he has drawn this:

Then there's "the call" again:

SQSPI :L + 5

He says: I will finish this later. Now I must draw SPIRAL 110.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question