Sunday, May 12, 2019

Logo Programming Language Essay Example | Topics and Well Written Essays - 3000 words

logo Programming Language - Essay ExampleRecursion is an alternative to REPEAT command. In ecumenical, Recursion is delineating as the process down the stairs which a function is delineate in such a way that the function being specify is applied within its own definition. The term shag 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 platform. Logo allows the recursion where a procedure calls itself.The concealed of recursive political 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 higher up program more general and flexible, we can use recursive pattern in the avocation way.In the above example, we use the variable member instead of word hello and a general relationship is defined that leave alone 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, Whats 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 head start 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 wordprint wordif equalp count word 1 stopdownup butlast wordprint wordendAnother application of recursion is to draw square spiral. The following is the code to draw square spiral.TO SQSPI L IF L 150 STOP FD L RT 90 SQSPI L + 5 END Suppose we give a command SQSPL degree CelsiusThat means he should write 100 on a piece of base and put it in hi s L pocket. IF (L 150) STOPThis is the stop crack. The turtle looks in the battlefront of his L pocket and sees 150. He asks himself if 100 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 loop again before he has swallowed 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 informality for later. L + 5 is 100+5. That is 105. because, 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 150) STOPThis 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 theres the action. He sees FD L. So he walks FD 105. Then RT 90. Now he has drawn this Then theres the call again SQSPI L + 5 He says I will finish this later. Now I must draw SPIRAL 110. He writes 110 on a paper and puts it in front of the o

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.