Wednesday, June 19, 2019

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

Logo Programming Language - Essay ExampleRecursion is an alternative to reverberate 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 use within its own definition. The term provoke be explained by taking a very simple example. Suppose, when the surfaces of two mirrors are placed parallel with separately opposite 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 enigma 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 how-dye-do and a general relationship is defined that provide transform hello into hell. That relationship is established victimisation 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 scrape 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 loot if the input has only one letter to downup wordprint wordif equalp count word 1 stopdownup butlast wordprint wordendanother(prenominal) 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 residuum Suppose we give a command SQSPL 100That means he should write 100 on a piece of paper and put it in his L pocket. IF ( L 150) STOPThis is the stop condition. The turtle looks in the front 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 cadaverous 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 inescapably 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 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