Learning Objectives
Video LessonsReference
Testing for UnderstandingRelated LinksLogo How-TosLogo in your browserLogo SoftwareLogo OrganizationsLogo ForumsThe work on this shelf is powered by you andMicroWorlds Web Player is officially supported under Internet Explorer or Netscape 4 or higher |
Writing ReportersFrom Procedures With Output in MicroWorlds EX Help: In MicroWorlds, primitives are either commands or reporters. Most of the procedures in the previous sections have been commands. You can also define procedures that are reporters. To do this, you must use the output command. The utility of defining reporters is immediately obvious when dealing with numbers. For example, define a procedure which squares its inputs using show. to square :x Trying this out shows you the result: square 5 But there is nothing more that you can do with it. You cannot use it as a building block in defining more complex procedures. For instance, you may want to compute the sum of the square of two numbers. To do this, you need to be able to communicate the result to another procedure. Square can be revised by replacing show with output: to square :x Now square is a reporter: square 5 MicroWorlds complains because there is no command at the beginning of the line, so it doesn't know what to do with its output. Try this instead: show square 5 Square can be used as the input to sum to compute the sum of two squared numbers: show sum square 5 square 3 Here is another arithmetic reporter that you can define, the average of two numbers: to average :x :y show average 20 50 Now you could combine the reporters by computing the square of the average: show square average 20 50 The procedures for words and lists which are reporters are ultimately more useful, and, in many cases, can function as tools. Tools are procedures that have many different purposes. A simple tool procedure doubles a word, linking it to itself: to double :wd show double "oops About the Center for Talent DevelopmentCenter for Talent Development (CTD), housed at Northwestern University's School of Education and Social Policy, is an accredited learning center and research facility that identifies, educates and supports gifted students and their families and serves as a leader in gifted education. Learn more about the Center for Talent Development. |
Leone Learning Systems, Inc. (LLS) is a North Shore company that provides online courses for kids anywhere and local teaching and tutoring services for students in Chicago and the Northern Suburbs of Chicagoland. LLS also provides a free geometry software package for children age 6 and up, and free resources for teachers and parents. This site includes information about classes taught, availability for tutoring, learning activities for kids, lesson plans, and ongoing software and curriculum research and development efforts. |
|