Sunday, February 23, 2020

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

Logo Programming Language - Essay Example 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 > 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 > 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 >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 >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. He writes 110 on a paper and puts it in front of the o

Thursday, February 6, 2020

Reference Paper Essay Example | Topics and Well Written Essays - 1500 words

Reference Paper - Essay Example Success stories are not created overnight and single-handedly and to say that most have been fashioned as a result of solitary efforts would be to make an assumption that has no basis in reality. The examples of this phenomenon abound in every walk of life. Movies and literature are teeming with success stories that talk of people and how the support that they received has played a great role in giving them the success that they have today. An excellent example of such a ‘person’ who achieved success as a result of the support that was given to him along his path to success is the character of â€Å"Babe† in the movie of the same name. Known as â€Å"Babe -the gallant pigâ€Å", this movie depicts the character of a pig who is raised on a farm owned by Farmer Hoggett, by a family of border collies and who aspires to be a sheep-dog one day. Babe is well liked by every animal on the farm as he is a friendly and polite animal, something which turns out to be the very secret behind his eventual success as a â€Å"sheep-dog†. The movie highlights the relationship that Babe has with most resident animals of the farm and how he is taught the value of politeness by â€Å"Maa†, the elderly ewe who also lives on the farm. The family of sheep dogs that raise Babe have a condescending attitude towards the other animals on the farm and they view most other animals as ‘stupid’. The ewe tells Babe that he too can become a sheep-dog and he can substitute his weaknesses by working on his strategy and ’asking’ the sheep to move, rather than to force them or to treat them roughly. As a result of this, babe, in spite of his small size and stature, is able to impress farmer Hogget with his abilities when he herds the chickens on the farm one day, separating the brown ones from the white. As a result of this, Farmer Hoggett decides to take Babe to the field the next day where he again impresses the farmer by his uncanny ability to guide and herd the sheep and in doing so, Babe