Part 1:
Fundamentals of LOGO
Introduction
Although the primary goal of our book is to provide a variety of interest worlds for you to investigate, some introduction to the fundamentals of programming using LOGO may be necessary. That is the goal of this part. However, given the diversity represented by the various versions of LOGO, we cannot present this material in a form that applies to all these systems. We advise you to use the userâs manual for your LOGO system as a companion to this section as we do not discuss how to
⢠start up LOGO
⢠edit LOGO programs
⢠use special purpose keys or the mouse to perform special functions such as interrupting, positioning the cursor, or deleting characters
⢠save or load LOGO programs from disk.
There may also be variations on exactly how the LOGO programs are written; we discuss some of these differences in Appendix I but, again, you should study your userâs manual to understand the details of your LOGO system.
We cover the basics that we feel are necessary to help you explore the topics presented in the rest of the book. In doing so, we hope to avoid an emphasis on minute details of LOGO as a programming language. We try to motivate and situate the various language constructs but, in some cases, this is not possible until you apply LOGO to the problems presented later and problems of your own.
Chapter 1:
Your First Encounters with LOGO
Every computer language has a set of primitive (built-in) objects. These can be classified into two sets: the set of procedures, or things that the language knows how to do, and the set of data types, or the types of things the language knows how to do things to. These two sets are tightly interrelated, since it is difficult to describe an action in a way that is completely independent from what is being acted on. This chapter presents some of the primitive LOGO objects and the actions that operate on them.
1.1 Words and Lists
Early programming languages emphasized the numerical capabilities of computers by providing numbers (integer and floating-point) as the primary fuel for the computational engine. The need to operate on groups of numbers repetitively and efficiently led to the addition of arrays (sets of numbers stored contiguously that could be accessed by providing an offset into their storage). More recently languages have also acknowledged the ability of the computer to process more than just numbers by introducing characters (letters represented by number codes) and strings (arrays of characters). In LOGO the emphasis is upon symbolic computation, operating on words and lists of words.
Words
LOGO (whose name is derived from the Greek word logos, which means âwordâ) takes a different approach. The basic data building blocks in LOGO are words. Here are some examples of words:
word
this
1234
abc 123
2.0
2e3
These words can be used for different things: They can be commands to tell LOGO to do something, they can be names for information we want to remember, or they can be the actual data (numbers, strings of letters) that we want to work with.
In order to treat a word as actual data, in general we precede it with a double quote character,â"â. The word is then composed of all characters until some âwhite spaceâ (space, tab, end-of-line, etc) is found.
Letâs see what the computer âthinksâ about this:
Welcome to Logo
? "word
You donât say what to do with "word.
This raises the next question: Now that we know about this simple data type, what can we (have the computer) do with it? This leads us to our first LOGO operation, the Print command:
? Print "word
word
Lists and Sentences
The next primitive data type is the list. A list is simply a sequence of elements that are words, or other lists. We write ...