rs@uunet.UU.NET (Rich Salz) (06/24/87)
Submitted by: Brian Harvey <bh@mit-amt> Mod.Sources: Volume 10, Number 25 Archive-Name: logo/Part05 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 5 (of 6)." # Contents: logoman.1 # Wrapped by rsalz@pineapple.bbn.com on Wed Jun 24 14:27:00 1987 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f logoman.1 -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"logoman.1\" else echo shar: Extracting \"logoman.1\" \(35585 characters\) sed "s/^X//" >logoman.1 <<'END_OF_logoman.1' X.ll 7.5i X.lt 7.5i X.po .2i X.pn 1 X.de TL X.sp 2 X.ft 3 X.ce X\\$1 X.sp 1 X.ft 1 X.. X.de PP X.sp 1 X.ti 5 X.fi X.ft 1 X.. X.de NB X.de NP X'sp 1 X.tl ''%'' X'bp +1 X'sp 2 X\\.. X.ch NP -1i X.. X.de NP X'bp +1 X'sp 2 X.. X.wh -1.0i NP X.TL "LSRHS Logo Manual" X.NB X.de EX X.ft 3 X.in +5 X.sp 1 X.nf X.. X.de EE X.ft 1 X.in -5 X.fi X.PP X.. X.de EC X.ft 1 X.in -5 X.sp 1 X.fi X.. X.de IN X.br X.in +5 X.. X.de OU X.sp 1 X.in -5 X.. X.de UB X.uf 3 X.cu 1 X\\$1 X.ft 1 X.uf 2 X.. X.PP X.UB "Introduction." XLogo is a computer programming language which was Xdesigned to be both simple to use and extremely powerful. It was Xdesigned by a group of computer scientists at MIT and at Bolt, Beranek, and XNewman. Its structure is based largely on the LISP language, which is Xwidely used in Artificial Intelligence research, but the notation has been Xchanged to make Logo far easier for a beginner than LISP. This manual Xdescribes a version of Logo for the PDP-11, originally written in C at the XBoston Children's Museum and extensively modified at the Lincoln-Sudbury XRegional High School. X.PP XThe power of Logo comes primarily from the idea of the \f2procedure\f1. A Xprocedure is simply something the computer "knows" how to do; some Xprocedures are built into Logo itself (these are called \f2primitive\f1 Xprocedures), while others are \f2defined\f1 by the programmer in terms of Xthese simple procedures. Defined procedures can be used as part of the Xdefinition of other procedures, so that a complicated program can be built Xin "layers" of complexity. This layered structure is analogous to the Xdescription of a complex machine in terms of building blocks: an automobile Xis made of a chassis, a drive train, an electrical system, and so on. The Xdrive train contains an engine, a transmission, a clutch, an axle, and so Xon. The transmission contains a housing, gears, and levers. A lever may Xinclude connecting joints at the ends and at a pivot point. Eventually the Xdescription of the automobile reaches the level of bolts and washers; these Xcorrespond to the primitive procedures in Logo. X.PP X.UB "Starting Logo." XUse the shell command \f3logo\f1 to start the Logo Xinterpreter. When Logo is running it will print a question mark (?) at the Xbeginning of a line to indicate that it is ready for you to type in a Logo Xinstruction. The instruction may print something on the terminal, or draw a Xline on a graphics display screen, or move a turtle around the floor. Then Xanother question mark is typed and you may give another instruction. (If Logo Xprints a "greater than" sign (>) instead of a question mark, it is Xin \f2procedure definition mode\f1, Xwhich will be described later. Type your system quit character X(control-G at Lincoln-Sudbury) to return to normal mode.) X.PP XIf an argument is used with the shell command \f3logo\f1, the argument is Xtaken as the name of a procedure, which Logo runs before doing anything Xelse. You can therefore create a shell script which will start Logo, run Xa procedure automatically, and (if you say "goodbye" at the end of the Xprocedure) exit. X.PP X.UB "Syntax." XUnlike most computer languages, Logo has an almost Xentirely uniform Xsyntax. That is, all of the different commands Logo understands are Xrepresented using the same notation: the name of a procedure is followed by Xits \f2inputs\f1, which may be \f2constants\f1 (like numbers) or else may Xbe the results of using other procedures. Here is a simple example: X.EX Xprint "hello X.EC XIn this Logo instruction, the primitive procedure \f3print\f1 is used with Xa constant input, the word \f3hello\f1. The quotation mark indicates that X\f3hello\f1 is being used to represent the word itself; without the Xquotation mark it would have been interpreted as the name of a procedure, Xjust as \f3print\f1 is the name of a procedure. In Logo, the \f3print\f1 Xprocedure always requires exactly one input, which is the thing to print. The Xinput can be a \f2word\f1, as in this example, or a \f2list\f1, which will Xbe explained later. (A \f2number\f1 is a special case of a word, and a X\f2sentence\f1 is a special case of a list.) Here is another example: X.EX Xprint first "hello X.EC XIn this instruction, the primitive procedure \f3first\f1 is used. This Xprocedure takes one input, a word, and has an \f2output\f1 which is the Xfirst letter of the word. The output from \f3first\f1 is used as the input Xto \f3print\f1, so what is printed is the letter \f3h\f1 rather than the Xword \f3hello\f1 as in the earlier example. X.PP XDon't confuse the \f2output\f1 from a procedure with what is \f2printed\f1 Xby the \f3print\f1 command. In Logo, the word "output" is not used to Xrefer to what is printed by a program, just as the word "input" does not Xmean something you type into the program. Instead, these words refer to Xobjects (words or lists) which are given to a procedure (inputs) or Xproduced by a procedure (outputs). A particular procedure has a fixed Xnumber of inputs and outputs. The number of inputs may be anything, Xincluding zero, whereas the number of outputs is either zero or one. A Xprocedure with an output (like \f3first\f1) is called an \f2operation\f1; one Xwithout an output (like \f3print\f1) is called a \f2command\f1. X.PP XSome operations only have two possible outputs: the word \f3true\f1 and Xthe word \f3false\f1. Such a procedure is called a \f2predicate\f1. Predicates Xare used to allow a program to carry out some instruction only if a Xparticular condition is met. By convention, predicates generally have Xnames ending with the letter "p". X.PP X.UB "Multiple inputs to operations." XSeveral Logo primitive procedures are Xoperations with two inputs. The arithmetic operations, like \f3sum\f1, are Xexamples of this. A special extension to Logo syntax allows such an operation Xto have more than two inputs by enclosing the operation and its inputs in Xparentheses or braces: X.EX X(sum 2 5 13 8.5) X.EC XAssociation is right to left. At least two inputs must be given, except for Xthe \f3list\f1 operation, which can take one input if parenthesized. X.PP X.UB "Multi-instruction lines." XIt is possible to put more than one instruction on the same line when you Xare typing to Logo. If you do this, it is recommended that you type a Xsemicolon (;) between the instructions for improved readability: X.EX Xprint "hello; print "goodbye X.EC XFor compatibility with other versions of Logo, it is permitted to leave out Xthe semicolon. Later in this manual, the phrase "instruction line" will Xmean one or more instructions on a line. X.PP X.UB "Multi-line instructions." XIt is possible to continue an instruction on Xa second line. To do this, end the first line with a backslash (\\), Ximmediately followed by the RETURN key. If you are typing a quoted word, Xyou must end the word (with a space, for example) before using the Xbackslash-RETURN combination. Inside a quoted word, backslash-RETURN Xmeans to put an actual RETURN as part of the word. X.PP X.UB "Comments." XIt is possible to include in an instruction line comments Xwhich are meant for human readers of your program (including yourself, next Xweek), and which are not Logo instructions. To do this, begin the comment Xwith an exclamation point (!). Everything after the exclamation point on the Xline will be ignored by Logo. For example: X.EX Xprint [Hi, there.] ! A friendly greeting. X.EC XHowever, the exclamation point does not begin a comment if it is part of a Xword or list (see below). You should type a space before the exclamation Xpoint, as in the example above, to make sure it will be interpreted as the Xbeginning of a comment. X.PP X.UB "Words." XEvery computer language deals with particular kinds Xof objects. Most languages, like FORTRAN or BASIC or Pascal, are best at Xdealing with numbers. Logo is a \f2list processing\f1 language, which is Xat its best with more complicated data structures. The two main categories Xof object are the \f2word\f1 and the \f2list\f1. X.PP XA \f2word\f1 is a string of characters. (A \f2character\f1 is a letter, Xdigit, space, or punctuation mark. Things like TAB and RETURN on the Xterminal keyboard are also characters, although they are not usually used Xas part of Logo words.) A word can be any length, including zero. The way Xto indicate a word as part of a Logo program is to use the quotation mark X(") before the word. The word begins with the character after the Xquotation mark and continues until a space, a tab, the end of the Xline, or one of these characters: X.EX X( ) [ ] { } " ; X.EC XA quotation mark immediately followed by a space or one of the other Xword-terminating characters indicates the \f2empty word\f1, which is a word Xof length zero. X.PP XPlease notice that, unlike most programming languages, Logo does not use Xquotation marks in pairs to delimit strings of characters. The following Xinstruction is an error: X.EX Xprint "aardvark" X.EC XThis is an error because the \f3print\f1 command is followed by \f2two\f1 Xwords, the word \f3aardvark\f1 and an empty word which is indicated by the Xsecond quotation mark. Since \f3print\f1 only uses one input, the second Xword has no purpose, and Logo gives the error message X.EX XYou don't say what to do with " X.EE XIn order to include one of the word-terminating characters in a word, you Xmust precede it with a backslash (\\). Do not confuse backslash with the Xregular slash (/) character. For example, this instruction: X.EX Xprint "\\(boo\\) X.EC Xwill print the five characters \f3(boo)\f1 as its result. The space Xcharacter may be included in a word by using a percent (%) instead of the Xspace. Therefore, the following are equivalent: X.EX Xprint "Hello%there. Xprint "Hello\\ there. X.EC XTo include a percent character or a backslash character in a word, you must Xprecede it with a backslash. X.PP X.UB "Numbers." XA number is a special case of a word, in which the Xcharacters are all digits. (That definition isn't quite complete, and will Xbe expanded in the next paragraph.) A number need not be preceded with a Xquotation mark. (This rule is possible because normally Logo interprets Xwords without quotation marks as the names of procedures, but there are no Xprocedures whose names begin with digits.) If a quotation mark is not Xused, then any nondigit terminates the word. X.PP XActually, numbers may be written in scientific notation. That is, they can Xinclude signs, decimal points, and a power of 10 by which the number is Xmultiplied. This \f2exponent\f1 is indicated by the letter \f3e\f1 Xfollowed by the integer power of 10. The following numbers have the Xsame value: X.EX X1000 X"1000 X1000.00 X1e3 X10.0e+2 X"+1.0e3 X10000e-1 X.EC XNotice that if the number begins with a sign it must be quoted. A quoted Xnumber still must begin with a digit or a sign, not with a Xdecimal point or a letter \f3e\f1. (The Xletter may be a capital \f3E\f1, by the way.) If a number is quoted, it Xmust end with one of the normal word-terminating characters. A number Xwhich contains only digits (no decimal point or exponent) is called Xan \f2integer\f1. Note that a number with a decimal point is not Xconsidered an integer even if the digits after the decimal point are Xall zero. X.PP XSince a number is a word, the usual character-manipulating procedures may Xbe applied to it. For example, X.EX Xprint first 1024 X.EC Xprints the digit \f31\f1 which is the first character of the number. In Xaddition, there are arithmetic procedures which apply specifically to numbers: X.EX Xprint sum 3 2 X.EC Xprints the number 5. These procedures will be listed later. X.PP X.UB "Lists." XA word can be thought of as a list of characters; for Xexample, the word \f3hello\f1 is a list of five letters. In Logo it is Xpossible to manipulate not only lists of characters but also lists of Xwords, lists of lists of words, and so on. This is a very powerful capability Xwhich allows very complicated data structures to be manipulated easily. To Xindicate a list in a program, you put square brackets ([ and ]) around the Xlist, and separate the list elements with spaces. For example: X.EX Xprint [This is a list of seven words.] X.EC XA list all of whose elements are words is called a \f2sentence\f1. Here Xis an example of a list which is not a sentence: X.EX Xprint [[This is a list][of two sentences.]] X.EE XWithin a bracketed list, square brackets delimit sub-lists (lists which are Xelements of the main list). The quotation mark, parentheses, and braces Xare not considered special within a bracketed list, unlike the rules for Xquoted words. A list may extend over more than one line; that is, if you Xhave typed an open square bracket ([) and have not yet typed the matching Xclose square bracket, the Logo instruction is not ended by typing the RETURN Xkey. X.PP X.UB "Variables." XA variable is an entity which has a \f2name\f1, which Xis a word, and a \f2thing\f1 (also called a \f2value\f1), which Xcan be any Logo object. Variables Xare used to "remember" a computed object for repeated or delayed use Xin a program. In Logo, the most common way that a variable acquires Xa value is that it is associated with an input to a user-written Xprocedure. In the following example, don't worry about the details Xof the format of the procedure, which will be explained later: X.EX Xto pff :sentence Xprint first first :sentence Xend X.EC XThis is the definition of a command with one input. The name of the Xcommand is \f3pff\f1. It has one input because in the "title line" (the Xone starting \f3to pff\f1) there is one variable name after the command Xname. The variable whose name is \f3sentence\f1 is associated with the Xfirst (and only, in this case) input to \f3pff\f1. In the line starting Xwith the word \f3print\f1, the notation \f3:sentence\f1 means "the \f2thing\f1 Xof the variable whose \f2name\f1 is \f3sentence\f1". (To refer to the Xname itself, quote it as you would any word.) If this procedure is used Xin a Logo instruction like this: X.EX Xpff [This is the poop.] X.EC Xthen the variable \f3sentence\f1 has the value \f3[This is the poop.]\f1. X.PP XIt is also possible to assign a value to a variable by an explicit XLogo instruction. There is a primitive procedure to do this: X.sp 1 X\f3make\f1 \(em Command, two inputs. X.IN XThe first input is the name of a variable (that is, it must be a word); the Xsecond is any Logo object. The effect of the command is to assign the Xsecond input as the value of the variable named by the first input. X.OU XIf you are accustomed to programming in a non-procedural language like XBASIC, you should strenuously avoid the temptation to overuse \f3make\f1; Xexplicit assignment is almost always the wrong thing to do in Logo. Total Xabstention is the best policy for a Logo beginner. X.PP XIn Logo, variables are \f2dynamically scoped\f1. That means that a Xvariable can "belong to" a particular procedure; such a variable can Xbe used by that procedure and by any procedure which is used by an Xinstruction within the procedure, but is not available to the procedure Xwhich invoked the owning procedure. In other words, such a \f2local\f1 Xvariable comes into being when the owning procedure starts running, and Xdisappears when that procedure is finished. It is possible for a Xprocedure with a local variable to use another procedure with a local Xvariable of the same name. In that case, the variable belonging to the X"inner" procedure is the one which is associated with the name as long Xas it exists; when the inner procedure is finished, the "hidden" Xvariable belonging to the outer procedure is again available. X.PP XA variable which is associated with the input to a procedure is Xautomatically local to that procedure. Other variables are normally X\f2global\f1: they are "permanent" and do not disappear when the Xprocedure in which they get their values finish. It is both possible Xand desirable to make such variables local, by an explicit instruction Xto that effect: X.sp 1 X\f3local\f1 \(em Command, one input. X.IN XThe input must be a word. A variable with that word as its name Xis created, local to the currently running procedure (that is, Xlocal to the procedure in which the \f3local\f1 command is used). X.OU XThe virtue of local variables is that they make procedures more Xindependent of one another than they would be if global variables Xwere used. In other words, if you use local variables consistently, Xthen nothing that happens in one procedure will change the values Xof variables used in another procedure. This makes it very much Xeasier to find program errors. X.PP X.UB "Case insensitivity." XNames of procedures (primitive or user-defined) and names of variables Xmay be typed in upper or lower case. They are converted internally to Xlower case. That is, the variables \f3foo\f1 and \f3FOO\f1 are the Xsame variable. Letters in other contexts are not converted to lower Xcase. For example, \f3equalp\f1 will report that the words \f3foo\f1 Xand \f3FOO\f1 are not equal. X.PP XNames of procedures and names of variables may include only letters, Xdigits, and the special characters period (.) and underscore (_). Also, Xnames of procedures are limited to 11 characters in some versions of Unix. X.PP X.UB "Primitive procedures to define user procedures." XThere are Xtwo ways to define your own procedure. The first way, using the \f3to\f1 Xcommand, is simple to learn but limited in flexibility. The second way, Xusing the \f3edit\f1 command, is more complicated to learn, but makes it Xeasy to make changes in your procedures. The \f3edit\f1 command uses the Xtext editing program \f3edt\f1, just as you might use it outside of Logo Xto edit a document you want to print. Once you've learned the special Xediting commands in \f3edt\f1, it's easy to use. The \f3to\f1 command makes Xit possible to begin programming in Logo without having learned how to use X\f3edt\f1. It just lets you type in your procedure definition, without any Xprovision for correcting errors or changing the definition of the procedure. XIt is fast and convenient for short procedures, but limited. X.sp 1 XThe \f3to\f1 command is unique, in Logo, in that its inputs are interpreted Xin a special way. The inputs aren't \f2evaluated\f1: Logo doesn't run any Xprocedures you name, or look up the values of any variables, before carrying Xout the \f3to\f1 command. The example below should make this clearer. X.sp 1 X\f3to\f1 \(em Command, special form, see below. X.IN XThis command takes a variable number of inputs. The first is the name Xof a procedure to be defined. The rest, if any, must be preceded by Xcolons, and are the names of variables to be used as inputs to the Xprocedure. Logo responds to the \f3to\f1 command by printing a X"greater than" sign (>) prompt, to show you that you are defining a procedure Xrather than entering commands to be executed immediately. You type Xthe instruction lines which make up the definition. When Xyou are done with the definition, type the special word \f3end\f1 on Xa line by itself. For example: X.sp 1 X.nf X\f3\z_?to twoprint :thing X\z_>print :thing X\z_>print :thing X\z_>end X\z_?\f1 X.fi X.sp 1 XThis example shows the definition of a procedure named \f3twoprint\f1, Xwhich has one input, named \f3thing\f1. The procedure you are defining Xwith the \f3to\f1 command must not already be defined. X.OU X\f3edit\f1 \(em Command, zero or one input. Abbreviation: \f3ed\f1 X.IN XThe input to this command must be a word, which is the name of a procedure, Xor a list of words, each of which is the name of a procedure. X(Unlike the \f3to\f1 command, but like all other Logo procedures, the X\f3edit\f1 command evaluates its input, so you must use a quotation mark Xbefore the procedure name, if only one is given, to indicate Xthat it is the name itself which is Xthe input to \f3edit\f1; otherwise Logo would actually run the procedure Xto calculate the input to \f3edit\f1.) The procedure you name may or may Xnot already be defined. Logo responds to the \f3edit\f1 command by running Xthe text editor \f3edt\f1, editing the definition of the procedure(s) named in Xits input. (If a procedure was not previously defined, Logo creates an Xinitial definition for it which contains only a title line and the end line.) XYou then edit the definition(s) with \f3edt\f1. When you write the file and Xleave \f3edt\f1, Logo will use the edited file as the definition(s) of the Xprocedure(s). You must not put anything in the file except procedure Xdefinitions; in other words, every nonempty line in the file must be between Xa "to" line and an "end" line. X.sp 1 XIf the \f3edit\f1 command is given with no input, \f3edt\f1 is given the same Xfile as from the last time you used the \f3edit\f1 command. This is a Xconvenience for editing the same procedure(s) repeatedly. X.sp 1 XIf, while editing, you change your mind and want to leave \f3edt\f1 Xwithout redefining anything, use the command \f3ESC ^Z\f1 instead of Xthe normal \f3^Z\f1. This special way of leaving \f3edt\f1 tells Logo Xnot to redefine your procedures. You have the choice, before exiting X\f3edt\f1, of writing or not writing the temporary file which contains Xthe definitions. If you don't write the file, another \f3edit\f1 command Xwith no input will re-read the previous contents of the temporary file; Xif you do, another \f3edit\f1 will re-read the new version. X.sp 1 XIf your Unix environment contains a variable named EDITOR, the contents of Xthat variable is used as the name of the text editor program instead of Xthe standard \f3edt\f1. The variable can contain a full pathname, or just Xa program name if the program can be found in /bin or /usr/bin. Your favorite Xeditor may not have a facility like \f3edt\f1's ESC ^Z to abort redefinition. X.OU X\f3show\f1 \(em Command, one input. Abbreviation: \f3po\f1 X.IN XThe input to this command is a word or a list of words. Each word must be Xthe name of a procedure. The command prints out the definition(s) of the Xprocedure(s) on your terminal. (The abbreviation \f3po\f1 stands for X\f3printout\f1, which is the name used for this command in some other versions Xof Logo.) X.OU X\f3pots\f1 \(em Command, no inputs. X.IN XThis command types at your terminal the title lines of all procedures Xyou've defined. The name is an abbreviation for "print out titles". X.OU X\f3erase\f1 \(em Command, one input. Abbreviation: \f3er\f1 X.IN XAs for the \f3show\f1 command, the input is either a word, naming one Xprocedure, or a list of words, naming more than one. The named procedures Xare erased, so that they are no longer defined. X.OU X.ti 5 X.UB "Primitive procedures to manipulate words and lists." XThere are Xprimitive procedures to print text objects on the terminal, to read Xthem from the terminal, to combine them into larger objects, to split Xthem into smaller objects, and to determine their size and nature: X.sp 1 X\f3print\f1 \(em Command, one input. Abbreviation: \f3pr\f1 X.IN XThe input, which may be a word or a list, is printed on the terminal, Xfollowed by a new line character. (That is, the terminal is positioned Xat the beginning of a new line after printing the object.) If the Xobject is a list, any sub-lists are delimited by square brackets, but Xthe entire object is not delimited by brackets. X.OU X\f3type\f1 \(em Command, one input. X.IN XThe input, which may be a word or a list, is printed on the terminal, X\f2without\f1 a new line character. (That is, the terminal remains Xpositioned at the end of the object after printing it.) Brackets Xare used as with the \f3print\f1 command. X.OU X\f3fprint\f1 \(em Command, one input. Abbreviation: \f3fp\f1 X.IN XThe input is printed as by the \f3print\f1 command, except that if it Xis a list (as opposed to a word) it is enclosed in square brackets. The Xname of the command is short for "full print". X.OU X\f3ftype\f1 \(em Command, one input. Abbreviation: \f3fty\f1 X.IN XThe input is printed as by the \f3type\f1 command, except that if it Xis a list, it is enclosed in square brackets. X.OU X\f3readlist\f1 \(em Operation, no inputs. Abbreviation: \f3rl\f1 X.IN XLogo waits Xfor a line to be typed by the user. The contents of the line are made Xinto a list, as though typed within square brackets as part of a Logo Xinstruction. (The user should not actually type brackets around the Xline, unless s/he desires a list of one element, which is a list Xitself.) That list is the output from the operation. X.OU X\f3request\f1 \(em Operation, no inputs. X.IN XA question mark is printed on the terminal as a prompt. Then Logo waits Xfor a line to be typed by the user, as for \f3readlist\f1. X.OU X\f3word\f1 \(em Operation, two inputs. X.IN XThe two inputs must be words. The output is a word which is the Xconcatenation of the two inputs. There is no space or other Xseparation of the two inputs in the output. X.OU X\f3sentence\f1 \(em Operation, two inputs. Abbreviation: \f3se\f1 X.IN XThe two inputs may be words or lists. The output is a list formed Xfrom the two inputs in this way: if either input is a word, that Xword becomes a member of the output list; if either input is a Xlist, the \f2members\f1 of that input become members of the Xoutput. Here are some examples: X.EX X.ta 2i 4i Xfirst input second input output X"hello "test [hello test] X"goodbye [cruel world] [goodbye cruel world] X[a b] [c d] [a b c d] X[] "garply [garply] X.EC XIf an input is the empty list, as in the last example above, it Xcontributes nothing to the output. X.OU X\f3list\f1 \(em Operation, two inputs. X.IN XThe output is a list of two elements, namely, the two inputs. The Xinputs may be words or lists. X.OU X\f3fput\f1 \(em Operation, two inputs. X.IN XThe first input may be any Logo object; the second must be a list. The Xoutput is a list which is identical with the second input except that Xit has an extra first member, namely, the first input. X.OU X\f3lput\f1 \(em Operation, two inputs. X.IN XThe first input may be any Logo object; the second must be a list. The Xoutput is a list which is identical with the second input except that Xit has an extra last member, namely, the first input. X.OU X\f3first\f1 \(em Operation, one input. X.IN XThe input may be any non-empty Logo object. If the input is a list, Xthe output is its first member. If the input is a word, the output is Xa single-letter word, namely the first letter of the input. If the Xinput is empty (a word or list of length zero) an error results. X.OU X\f3last\f1 \(em Operation, one input. X.IN XThe input may be any non-empty Logo object. If the input is a list, Xthe output is its last member. If the input is a word, the output is Xa single-letter word, namely the last letter of the input. If the Xinput is empty (a word or list of length zero) an error results. X.OU X\f3butfirst\f1 \(em Operation, one input. Abbreviation: \f3bf\f1 X.IN XThe input may be any non-empty Logo object. If the input is a list, Xthe output is a list equal to the input list with the first member Xremoved. (If the input list has only one member, the output is Xthe \f2empty list\f1, a list of zero members.) If the input is Xa word, the output is a word equal to the input word with the Xfirst letter removed. (If the input is a single-letter word, the Xoutput is the \f2empty word\f1.) If the input is empty, an Xerror results. X.OU X\f3butlast\f1 \(em Operation, one input. Abbreviation: \f3bl\f1 X.IN XThe input may be any non-empty Logo object. If the input is a list, Xthe output is a list equal to the input list with the last member Xremoved. (If the input list has only one member, the output is Xthe \f2empty list\f1, a list of zero members.) If the input is Xa word, the output is a word equal to the input word with the Xlast letter removed. (If the input is a single-letter word, the Xoutput is the \f2empty word\f1.) If the input is empty, an Xerror results. X.OU X\f3count\f1 \(em Operation, one input. X.IN XThe input may be any Logo object. If the input is a list, the Xoutput is a number indicating the number of members in the list. (Note: Xonly top-level members are counted, not members of members. The count Xof the list X.EX X[[This is] [a list]] X.EC Xis 2, not 4.) If the input is a word, the output is the number of Xletters (or other characters) in the word. Remember that in Logo a Xnumber is just a particular kind of word, so the output from \f3count\f1 can Xbe manipulated like any other Logo word. X.OU X\f3emptyp\f1 \(em Operation (predicate), one input. X.IN XThe input can be any Logo object. The output is the word \f3true\f1 if Xthe input is of length zero (i.e., it is the empty word or the empty Xlist). The output is the word \f3false\f1 otherwise. X.OU X\f3wordp\f1 \(em Operation (predicate), one input. X.IN XThe input can be any Logo object. The output is the word \f3true\f1 if Xthe input is a word. The output is the word \f3false\f1 if the input Xis a list. X.OU X\f3sentencep\f1 \(em Operation (predicate), one input. X.IN XThe input can be any Logo object. The output is the word \f3true\f1 if Xthe input is a sentence, i.e., a list of words. The output is the word X\f3false\f1 if the input is a word, or if any member of the input is a Xlist. X.OU X\f3is\f1 \(em Operation (predicate), two inputs. X.IN XThe inputs can be any Logo objects. The output is the word \f3true\f1 if Xthe two inputs are identical. That is, they must be of the same type X(both words or both lists), they must have the same count, and their Xmembers (if lists) or their characters (if words) must be identical. The Xoutput is the word \f3false\f1 otherwise. (Note: this is an exception Xto the convention that names of predicates end with the letter "p".) X.OU X\f3memberp\f1 \(em Operation (predicate), two inputs. X.IN XIf the second input is a word, the first input must be a word of Xlength one (a single character), and the output is \f3true\f1 if and Xonly if the first input is contained in the second as a character. If Xthe second input is a list, the first input can be any Logo object, Xand the output is \f3true\f1 if and only if the first input is a member Xof the second input. (Note that this is member, not subset.) X.OU X\f3item\f1 \(em Operation, two inputs. Abbreviation: \f3nth\f1 X.IN XThe first input must be a positive integer less than or equal to Xthe \f3count\f1 of the second input. If the second input is a word, Xthe output is a word of length one containing the selected character Xfrom the word. (Items are numbered from 1, not 0.) If the second input Xis a list, the output is the selected member of the list. X.OU X.ti 5 X.UB "Primitive procedures for turtles and graphics." XAn important Xpart of the Logo environment is a rich set of applications to which the Xcomputer can be directed. The most important of these is \f2turtle Xgeometry\f1, a way of describing paths of motion in a plane which is Xwell-suited to computer programming. There are two ways to use the Xturtle procedures. First, you can control a \f2floor turtle\f1, a small Xrobot which can move one the floor or on a table under computer Xcontrol. Second, you can use a \f2display turtle\f1 to draw pictures Xon the TV screen of a graphics terminal. X.PP XEach computer center has a different variety of graphics hardware Xavailable. Floor turtles are very different from display turtles, but also Xeach kind of display terminal has different characteristics. For example, Xsome terminals can draw in several colors; others can't. The following Xdescriptions of graphics primitives explain the "best" case for each one Xand mention restrictions on some graphics devices. X.PP XThe floor turtle can draw pictures on paper, because it has a pen Xattached to its "belly": the underside of the turtle. Since it is Xa mechanical device, however, it is not very precise; the pictures Xyou get may not be exactly like what your program specifies. A more Xinteresting way to use the floor turtle is to take advantage of its X\f2touch sensors\f1. Switches under the turtle's dome allow the computer Xto know when the turtle bumps into an obstacle. You can use this Xinformation to write programs to get around obstacles or to follow Xa maze. X.PP XThe display turtle lives on the surface of a TV screen. It can draw Xpictures more precisely than the floor turtle, since it does not Xmeasure distances and angles mechanically. It is also faster than Xthe floor turtle. When using the display turtle, remember that Xit interprets commands relative to its own position and direction, Xjust as the floor turtle does. The command \f3left\f1, for example, Xturns the turtle to its own left, which may or may not be toward Xthe left side of the TV screen. X.sp 1 X\f3turtle\f1 \(em Command, one input. Abbreviation: \f3tur\f1 X.IN XThe input is the name of a turtle. You can only control one turtle Xat a time, so using this command a second time releases the turtle Xpreviously selected. The names of floor turtles are numbers like X\f30\f1 and \f31\f1. If you are using Xa graphics display terminal (not just a text display trminal), you can Xcontrol the display turtle by using the word \f3display\f1 (or the Xabbreviation \f3dpy\f1) as the turtle name. (As usual, the word Xmust be preceded by a quotation mark.) If you use a graphics primitive Xwithout selecting a turtle, Logo assumes that you want to use the Xdisplay turtle. But once you select a floor turtle, you must say X\f3turtle "display\f1 explicitly to switch to the display. X.sp 1 XThe word \f3off\f1 as input to the \f3turtle\f1 command releases a floor Xturtle, if you have one, or turns off the graphics display if you have Xbeen using the display turtle. This also happens when you leave Logo. X.OU X\f3forward\f1 \(em Command, one input. Abbreviation: \f3fd\f1 X.IN XThe input is a number, the distance you would like the turtle Xto move. For a floor turtle, the unit of distance is however Xfar the turtle can travel in 1/30 second. For a display turtle, Xthe unit is one dot on the TV screen. (Note: on some displays, one Xdot horizontally may not be the same length as one dot vertically. The X\f3setscrunch\f1 command allows you to control the Xrelative sizes so that squares come out Xsquare.) The turtle moves in whatever direction it is pointing Xwhen you use the command. X.OU X\f3back\f1 \(em Command, one input. Abbreviation: \f3bk\f1 X.IN XThe input is a number, a distance to move, as in the \f3forward\f1 Xcommand. The difference is that the turtle moves backward, i.e., Xin the direction exactly opposite to the way it's pointing. X.OU X\f3left\f1 \(em Command, one input. Abbreviation: \f3lt\f1 X.IN XThe input is a number, the number of degrees of angle through Xwhich the turtle should turn counterclockwise. This command Xdoes not change the \f2position\f1 of the turtle, but merely Xits \f2heading\f1 (the direction in which it points). The Xturn will be only approximately correct for the floor turtle, Xbecause of mechanical errors. For the display turtle, the Xangle will be perfectly reproducible, although it may not look Xquite right on the screen because of the difference in size Xbetween horizontal and vertical dots. Nevertheless, a display Xturtle program will work in the sense that when the turtle is Xsupposed to return to its starting point, it will do so. X.OU X\f3right\f1 \(em Command, one input. Abbreviation: \f3rt\f1 X.IN XThe input is a number; the turtle turns through the specified Xnumber of degrees clockwise. X.OU X\f3penup\f1 \(em Command, no inputs. Abbreviation: \f3pu\f1 X.IN XThis command tells the turtle to raise its pen from the paper, Xso that it does not leave a trace when it moves. In the case Xof the display turtle, there is no physical pen to move Xmechanically, but the effect is the same: any \f3forward\f1 or X\f3back\f1 commands after this point do not draw a line. The Xfloor turtle starts with its pen up; the display turtle starts Xwith its pen down. Note: the floor turtle will not move on Xthe carpet correctly with its pen down; put it on a smooth Xsurface if you want to draw pictures. X.OU END_OF_logoman.1 if test 35585 -ne `wc -c <logoman.1`; then echo shar: \"logoman.1\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of archive 5 \(of 6\). cp /dev/null ark5isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. echo "Now see the README" rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0