home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / doslogo.zip / LOGOROOT.ZIP / LOGOMAN.MEM < prev    next >
Text File  |  1990-09-10  |  110KB  |  2,098 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.                                   LOGO Manual
  23.  
  24.                           VAX/VMS Internal Version 1.0
  25.  
  26.  
  27.  
  28.                                  Meyer Billmers
  29.  
  30.                          Digital Equipment Corporation
  31.  
  32.                                   Marlboro, MA
  33.  
  34.  
  35.                                  October, 1983
  36.  
  37.  
  38.  
  39.  
  40.                                    CONTENTS
  41.  
  42.  
  43.  
  44. CHAPTER 1       INTRODUCTION
  45.  
  46.  
  47. CHAPTER 2       USING LOGO
  48.  
  49.         2.1     STARTING LOGO  . . . . . . . . . . . . . . . . . . 2-1
  50.         2.2     SYNTAX . . . . . . . . . . . . . . . . . . . . . . 2-1
  51.         2.3     MULTIPLE INPUTS TO OPERATIONS  . . . . . . . . . . 2-2
  52.         2.4     MULTI-INSTRUCTION LINES  . . . . . . . . . . . . . 2-3
  53.         2.5     MULTI-LINE INSTRUCTIONS  . . . . . . . . . . . . . 2-3
  54.         2.6     COMMENTS . . . . . . . . . . . . . . . . . . . . . 2-3
  55.         2.7     WORDS  . . . . . . . . . . . . . . . . . . . . . . 2-3
  56.         2.8     NUMBERS  . . . . . . . . . . . . . . . . . . . . . 2-4
  57.         2.9     LISTS  . . . . . . . . . . . . . . . . . . . . . . 2-5
  58.         2.10    VARIABLES  . . . . . . . . . . . . . . . . . . . . 2-6
  59.  
  60.  
  61. CHAPTER 3       LOGO PRIMITIVE PROCEDURES
  62.  
  63.         3.1     DEFINING USER PROCEDURES . . . . . . . . . . . . . 3-2
  64.         3.2     MANIPULATING WORDS AND LISTS . . . . . . . . . . . 3-4
  65.         3.3     TURTLES AND GRAPHICS . . . . . . . . . . . . . . . 3-8
  66.         3.4     ARITHMETIC . . . . . . . . . . . . . . . . . . .  3-15
  67.         3.5     CONDITIONAL EXECUTION  . . . . . . . . . . . . .  3-18
  68.         3.6     FILE INPUT AND OUTPUT  . . . . . . . . . . . . .  3-20
  69.         3.7     PROCEDURE EXIT . . . . . . . . . . . . . . . . .  3-22
  70.         3.8     PROPERTY LISTS . . . . . . . . . . . . . . . . .  3-23
  71.         3.9     PAUSING  . . . . . . . . . . . . . . . . . . . .  3-24
  72.         3.10    MISCELLANEOUS PRIMITIVES . . . . . . . . . . . .  3-26
  73.  
  74.  
  75. CHAPTER 4       THE LOGO LIBRARY
  76.  
  77.  
  78. INDEX
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.                                CHAPTER 1
  94.  
  95.                               INTRODUCTION
  96.  
  97.  
  98.  
  99.  
  100.      Logo is a computer programming language which was  designed  to  be
  101.      both  simple  to  use and extremely powerful.  It was designed by a
  102.      group of computer scientists at  MIT  and  at  Bolt,  Beranek,  and
  103.      Newman.  Its structure is based largely on the LISP language, which
  104.      is  widely  used  in  Artificial  Intelligence  research,  but  the
  105.      notation  has  been  changed to make Logo far easier for a beginner
  106.      than LISP.  This manual describes a version of Logo for the PDP-11,
  107.      originally  written  in  C  at  the  Boston  Children's  Museum and
  108.      extensively modified at the Lincoln-Sudbury Regional  High  School.
  109.      This  version  has  been  modified  to  run under VAX/VMS; it is an
  110.      internal  version  to  Digital,  and  may  not  be  used  for   any
  111.      profit-making  purposes.  Where VMS-specific functionality has been
  112.      incorporated, it will be so noted.
  113.  
  114.                                                               procedure     The power of Logo comes primarily from the idea of  the  procedure.
  115.      A  procedure  is  simply  something the computer "knows" how to do;
  116.      some procedures are  built  into  Logo  itself  (these  are  called
  117.      primitive                                 defined     primitive  procedures),  while others are defined by the programmer
  118.      in terms of these simple procedures.   Defined  procedures  can  be
  119.      used  as  part  of  the  definition  of other procedures, so that a
  120.      complicated program can be built in "layers" of  complexity.   This
  121.      layered  structure  is  analogous  to  the description of a complex
  122.      machine in terms of building blocks:  an automobile is  made  of  a
  123.      chassis, a drive train, an electrical system, and so on.  The drive
  124.      train contains an engine, a transmission, a clutch, an axle, and so
  125.      on.   The  transmission  contains  a housing, gears, and levers.  A
  126.      lever may include connecting joints at the  ends  and  at  a  pivot
  127.      point.   Eventually  the  description of the automobile reaches the
  128.      level of bolts and  washers;  these  correspond  to  the  primitive
  129.      procedures in Logo.
  130.  
  131.      Additionally,  LOGO  enables  the  visualization   of   programming
  132.      concepts  by  making graphic presentation easy.  This is done using
  133.      "turtle graphics".  Depending on the implementation and  the  site,
  134.      LOGO  will support a "display turtle" capable of moving around on a
  135.      graphic terminal and drawing figures, or  a  "floor  turtle"  which
  136.      moves  on  the  floor  on wheels and traces with a pen in its body.
  137.      You should check with your system manager to  see  which  kinds  of
  138.      turtles are available on your system.
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.                                CHAPTER 2
  153.  
  154.                                USING LOGO
  155.  
  156.  
  157.  
  158.      This chapter briefly describes the use of  LOGO,  its  syntax,  and
  159.      some  helpful  facilities for getting about.  Some familiarity with
  160.      programming and computers is assumed; the reader with no  computing
  161.      experience  is  referred  to some of the tutorial-level books about
  162.      LOGO.
  163.  
  164.  
  165.  
  166.      2.1  STARTING LOGO
  167.  
  168.  
  169.                          logo     Use the VMS command logo to start the Logo interpreter.  When  Logo
  170.      is running it will print an asterisk (*) at the beginning of a line
  171.      to indicate that it is ready for you to type in a Logo instruction.
  172.      The instruction may print something on the terminal, or draw a line
  173.      on a graphics display screen, or move a turtle  around  the  floor.
  174.      Then   another   asterisk   is  typed  and  you  may  give  another
  175.      instruction.  (If Logo prints a "greater than" sign (>) instead  of
  176.                                 procedure definition mode     an  asterisk,  it  is  in  procedure definition mode, which will be
  177.      described later.   Type  the  interrupt  character  (control-C)  to
  178.      return to normal mode.)
  179.  
  180.                                                  logo     If an argument is used with the VMS command logo, the  argument  is
  181.      taken  as  the  name  of  a procedure, which Logo runs before doing
  182.      anything else.  You can therefore create a command procedure  which
  183.      will  start  Logo,  run  a procedure automatically, and (if you say
  184.      "goodbye" at the end of the procedure) exit.
  185.  
  186.  
  187.  
  188.      2.2  SYNTAX
  189.  
  190.  
  191.      Unlike most computer languages, Logo has an almost entirely uniform
  192.      syntax.   That  is,  all of the different commands Logo understands
  193.      are represented using the same notation:  the name of  a  procedure
  194.                         inputs               constants     is followed by its inputs, which may be constants (like numbers) or
  195.      else may be the results of  using  other  procedures.   Here  is  a
  196.      simple example:
  197.  
  198. USING LOGO                                                    Page 2-2
  199.  
  200.  
  201.           print "hello
  202.  
  203.                                                          print     In this Logo instruction, the primitive  procedure  print  is  used
  204.                                            hello     with  a  constant  input,  the  word  hello.   The  quotation  mark
  205.                     hello     indicates that hello is being used to represent  the  word  itself;
  206.      without  the  quotation  mark it would have been interpreted as the
  207.                                   print     name of a procedure, just as print is the name of a procedure.   In
  208.                 print     Logo,  the print procedure always requires exactly one input, which
  209.                                                      word     is the thing to print.  The  input  can  be  a  word,  as  in  this
  210.                     list                                     number     example,  or a list, which will be explained later.  (A number is a
  211.                                    sentence     special case of a word, and a sentence  is  a  special  case  of  a
  212.      list.) Here is another example:
  213.  
  214.           print first "hello
  215.  
  216.                                                   first     In this instruction, the primitive procedure first is  used.   This
  217.                                                      output     procedure  takes  one input, a word, and has an output which is the
  218.                                                 first     first letter of the word.  The output from first  is  used  as  the
  219.                print                                   h     input  to print, so what is printed is the letter h rather than the
  220.           hello     word hello as in the earlier example.
  221.  
  222.                        output                                printed     Don't confuse the output from a procedure with what is  printed  by
  223.          print     the print command.  In Logo, the word "output" is not used to refer
  224.      to what is printed by a program, just as the word "input" does  not
  225.      mean  something  you  type  into the program.  Instead, these words
  226.      refer to objects (words or lists) which are given  to  a  procedure
  227.      (inputs)  or  produced  by  a  procedure  (outputs).   A particular
  228.      procedure has a fixed number of inputs and outputs.  The number  of
  229.      inputs  may  be  anything,  including  zero,  whereas the number of
  230.      outputs is either zero or one.  A procedure with  an  output  (like
  231.      first                 operation                              print     first)  is  called an operation; one without an output (like print)
  232.                  command     is called a command.
  233.  
  234.                                                                true     Some operations only have two possible outputs:  the word true  and
  235.                   false                                       predicate     the   word   false.   Such  a  procedure  is  called  a  predicate.
  236.      Predicates  are  used  to  allow  a  program  to  carry  out   some
  237.      instruction  only if a particular condition is met.  By convention,
  238.      predicates generally have names ending with the letter "p".
  239.  
  240.  
  241.  
  242.      2.3  MULTIPLE INPUTS TO OPERATIONS
  243.  
  244.  
  245.      Several Logo primitive procedures are operations with  two  inputs.
  246.                                          sum     The  arithmetic  operations,  like  sum,  are  examples of this.  A
  247.      special extension to Logo syntax allows such an operation  to  have
  248.      more  than  two inputs by enclosing the operation and its inputs in
  249.      parentheses or braces:
  250.  
  251.           (sum 2 5 13 8.5)
  252.  
  253.      Association is right to left.  At least two inputs must  be  given,
  254.                        list     except  for  the  list  operation,  which  can  take  one  input if
  255.      parenthesized.
  256.  
  257. USING LOGO                                                    Page 2-3
  258.  
  259.  
  260.      2.4  MULTI-INSTRUCTION LINES
  261.  
  262.  
  263.      It is possible to put more than one instruction on  the  same  line
  264.      when  you  are  typing  to  Logo.  To do this, type a semicolon (;)
  265.      between the instructions:
  266.  
  267.           print "hello; print "goodbye
  268.  
  269.      Later in this manual, the phrase "instruction line" will  mean  one
  270.      or more instructions on a line.
  271.  
  272.  
  273.  
  274.      2.5  MULTI-LINE INSTRUCTIONS
  275.  
  276.  
  277.      It is possible to continue an instruction on a second line.  To  do
  278.      this, end the first line with a backslash (\), immediately followed
  279.      by the RETURN key.  If you are typing a quoted word, you  must  end
  280.      the   word   (with   a   space,   for  example)  before  using  the
  281.      backslash-RETURN    combination.     Inside    a    quoted    word,
  282.      backslash-RETURN means to put an actual RETURN as part of the word.
  283.  
  284.  
  285.  
  286.      2.6  COMMENTS
  287.  
  288.  
  289.      It is possible to include in an instruction line comments which are
  290.      meant  for  human readers of your program (including yourself, next
  291.      week), and which are not Logo instructions.  To do this, begin  the
  292.      comment  with  an  exclamation  point  (!).   Everything  after the
  293.      exclamation point on  the  line  will  be  ignored  by  Logo.   For
  294.      example:
  295.  
  296.           print [Hi, there.] !  A friendly greeting.
  297.  
  298.      However, the exclamation point does not begin a comment  if  it  is
  299.      part of a word or list (see below).  You should type a space before
  300.      the exclamation point, as in the example above,  to  make  sure  it
  301.      will be interpreted as the beginning of a comment.
  302.  
  303.  
  304.  
  305.      2.7  WORDS
  306.  
  307.  
  308.      Every computer language deals with  particular  kinds  of  objects.
  309.      Most  languages,  like  FORTRAN  or  BASIC  or  Pascal, are best at
  310.                                       list processing     dealing with numbers.  Logo is a list processing language, which is
  311.      at  its  best  with more complicated data structures.  The two main
  312.                                   word         list     categories of object are the word and the list.
  313.  
  314. USING LOGO                                                    Page 2-4
  315.  
  316.  
  317.        word                                character     A word is a string of characters.  (A character is a letter, digit,
  318.      space,  or  punctuation  mark.   Things  like TAB and RETURN on the
  319.      terminal keyboard  are  also  characters,  although  they  are  not
  320.      usually  used  as  part  of  Logo words.) A word can be any length,
  321.      including zero.  The way to indicate a  word  as  part  of  a  Logo
  322.      program is to use the quotation mark (") before the word.  The word
  323.      begins with the character after the quotation  mark  and  continues
  324.      until  a  space,  a  tab,  the  end  of  the  line, or one of these
  325.      characters:
  326.  
  327.           ( ) [ ] { } " ;
  328.  
  329.      A quotation mark immediately followed by a  space  or  one  of  the
  330.                                                        empty word     other  word-terminating  characters indicates the empty word, which
  331.      is a word of length zero.
  332.  
  333.      Please notice that, unlike most programming  languages,  Logo  does
  334.      not  use quotation marks in pairs to delimit strings of characters.
  335.      The following instruction is an error:
  336.  
  337.           print "aardvark"
  338.  
  339.                                    print                             two     This is an error because the  print  command  is  followed  by  two
  340.                         aardvark     words,  the  word  aardvark and an empty word which is indicated by
  341.                                        print     the second quotation mark.  Since print only uses  one  input,  the
  342.      second word has no purpose, and Logo gives the error message
  343.  
  344.           There's something extra on the line.   print  takes  only  one
  345.           input.
  346.  
  347.      In order to include one of the  word-terminating  characters  in  a
  348.      word,  you  must  precede  it with a backslash (\).  Do not confuse
  349.      backslash with the regular slash (/) character.  For example,  this
  350.      instruction:
  351.  
  352.           print "\(boo\)
  353.  
  354.                                     (boo)     will print the five characters (boo)  as  its  result.   The  space
  355.      character  may be included in a word by using a percent (%) instead
  356.      of the space.  Therefore, the following are equivalent:
  357.  
  358.           print "Hello%there.  print "Hello\ there.
  359.  
  360.      To include a percent character or a backslash character in a  word,
  361.      you must precede it with a backslash.
  362.  
  363.  
  364.  
  365.      2.8  NUMBERS
  366.  
  367.  
  368.      A number is a special case of a word, in which the  characters  are
  369.      all  digits.   (That  definition  isn't quite complete, and will be
  370.      expanded in the next paragraph.) A number need not be preceded with
  371.      a  quotation  mark.   (This  rule is possible because normally Logo
  372.  
  373. USING LOGO                                                    Page 2-5
  374.  
  375.  
  376.      interprets  words  without  quotation  marks  as   the   names   of
  377.      procedures,  but  there  are  no  procedures whose names begin with
  378.      digits.) If a  quotation  mark  is  not  used,  then  any  nondigit
  379.      terminates the word.
  380.  
  381.      Actually, numbers may be written in scientific notation.  That  is,
  382.      they  can include signs, decimal points, and a power of 10 by which
  383.                                      exponent     the number is multiplied.  This exponent is indicated by the letter
  384.      e     e  followed by the integer power of 10.  The following numbers have
  385.      the same value:
  386.  
  387.           1000 "1000 1000.00 1e3 10.0e+2 "+1.0e3 10000e-1
  388.  
  389.      Notice that if the number begins with a sign it must be quoted.   A
  390.      quoted  number  still must begin with a digit or a sign, not with a
  391.                                e                                  E     decimal point or a letter e.  (The letter may be a  capital  E,  by
  392.      the way.) If a number is quoted, it must end with one of the normal
  393.      word-terminating characters.  A number which contains  only  digits
  394.                                                    integer     (no  decimal  point or exponent) is called an integer.  Note that a
  395.      number with a decimal point is not considered an  integer  even  if
  396.      the digits after the decimal point are all zero.
  397.  
  398.      Since  a  number  is  a  word,  the  usual   character-manipulating
  399.      procedures may be applied to it.  For example,
  400.  
  401.           print first 1024
  402.  
  403.                       1     prints the digit 1 which is the first character of the number.   In
  404.      addition,  there are arithmetic procedures which apply specifically
  405.      to numbers:
  406.  
  407.           print sum 3 2
  408.  
  409.      prints the number 5.  These procedures will be listed later.
  410.  
  411.  
  412.  
  413.      2.9  LISTS
  414.  
  415.  
  416.      A word can be thought of as a list of characters; for example,  the
  417.            hello     word  hello  is  a list of five letters.  In Logo it is possible to
  418.      manipulate not only lists of characters but also  lists  of  words,
  419.      lists  of  lists  of  words,  and  so  on.  This is a very powerful
  420.      capability which allows very  complicated  data  structures  to  be
  421.      manipulated  easily.   To  indicate  a  list  in a program, you put
  422.      square brackets ([ and ]) around the list, and  separate  the  list
  423.      elements with spaces.  For example:
  424.  
  425.           print [This is a list of seven words.]
  426.  
  427.                                                         sentence     A list all of whose elements are words is called a sentence.   Here
  428.      is an example of a list which is not a sentence:
  429.  
  430.           print [[This is a list][of two sentences.]]
  431.  
  432. USING LOGO                                                    Page 2-6
  433.  
  434.  
  435.      Within a bracketed list, square brackets delimit  sub-lists  (lists
  436.      which  are  elements  of  the  main  list).   The  quotation  mark,
  437.      parentheses,  and  braces  are  not  considered  special  within  a
  438.      bracketed  list,  unlike  the  rules  for quoted words.  A list may
  439.      extend over more than one line; that is, if you have typed an  open
  440.      square bracket ([) and have not yet typed the matching close square
  441.      bracket, the Logo instruction is not ended  by  typing  the  RETURN
  442.      key.
  443.  
  444.  
  445.  
  446.      2.10  VARIABLES
  447.  
  448.  
  449.                                          name     A variable is an entity which has a name, which is a  word,  and  a
  450.      thing                    value     thing  (also  called  a  value),  which  can  be  any  Logo object.
  451.      Variables are used to "remember" a computed object for repeated  or
  452.      delayed  use  in  a  program.   In Logo, the most common way that a
  453.      variable acquires a value is that it is associated with an input to
  454.      a  user-written  procedure.   In the following example, don't worry
  455.      about the details of the format of the  procedure,  which  will  be
  456.      explained later:
  457.  
  458.           to pff :sentence
  459.  
  460.           print first first :sentence
  461.  
  462.           end
  463.  
  464.      This is the definition of a command with one input.   The  name  of
  465.                       pff     the  command  is pff.  It has one input because in the "title line"
  466.                        to pff     (the one starting to pff) there is  one  variable  name  after  the
  467.                                                   sentence     command  name.   The  variable whose name is sentence is associated
  468.                                                       pff     with the first (and only, in this case) input to pff.  In the  line
  469.                                 print               :sentence     starting  with  the  word  print, the notation :sentence means "the
  470.      thing                       name    sentence     thing of the variable whose name is sentence".  (To  refer  to  the
  471.      name  itself, quote it as you would any word.) If this procedure is
  472.      used in a Logo instruction like this:
  473.  
  474.           pff [This is the poop.]
  475.  
  476.                        sentence               [This is the poop.]     then the variable sentence has the value [This is the poop.].
  477.  
  478.      It is also possible to assign a value to a variable by an  explicit
  479.      Logo instruction.  There is a primitive procedure to do this:
  480.  
  481.      make     make -- Command, two inputs.
  482.  
  483.           The first input is the name of a variable (that is, it must be
  484.           a  word);  the  second  is any Logo object.  The effect of the
  485.           command is to assign the second input  as  the  value  of  the
  486.           variable named by the first input.
  487.  
  488.      If you are accustomed to programming in a  non-procedural  language
  489.      like  BASIC, you should strenuously avoid the temptation to overuse
  490.  
  491. USING LOGO                                                    Page 2-7
  492.  
  493.  
  494.      make     make; explicit assignment is almost always the wrong thing to do in
  495.      Logo.  Total abstention is the best policy for a Logo beginner.
  496.  
  497.                              dynamically  scoped     In Logo, variables are  dynamically  scoped.   That  means  that  a
  498.      variable  can  "belong  to" a particular procedure; such a variable
  499.      can be used by that procedure and by any procedure which is used by
  500.      an  instruction  within  the procedure, but is not available to the
  501.      procedure which invoked the owning procedure.  In other words, such
  502.         local     a  local variable comes into being when the owning procedure starts
  503.      running, and disappears when that procedure  is  finished.   It  is
  504.      possible  for  a  procedure  with  a  local variable to use another
  505.      procedure with a local variable of the same name.   In  that  case,
  506.      the variable belonging to the "inner" procedure is the one which is
  507.      associated with the name as long  as  it  exists;  when  the  inner
  508.      procedure is finished, the "hidden" variable belonging to the outer
  509.      procedure is again available.
  510.  
  511.      A variable which is associated with the input  to  a  procedure  is
  512.      automatically   local  to  that  procedure.   Other  variables  are
  513.               global     normally global:  they are "permanent" and do  not  disappear  when
  514.      the  procedure  in  which they get their values finish.  It is both
  515.      possible and desirable to make such variables local, by an explicit
  516.      instruction to that effect:
  517.  
  518.      local     local -- Command, one input.
  519.  
  520.           The input must be a word.  A variable with that  word  as  its
  521.           name  is  created,  local  to  the currently running procedure
  522.                                                         local          (that is, local to the procedure in which the local command is
  523.           used).
  524.  
  525.      The virtue of local variables is that  they  make  procedures  more
  526.      independent  of  one another than they would be if global variables
  527.      were  used.   In  other  words,  if   you   use   local   variables
  528.      consistently,  then  nothing  that  happens  in  one procedure will
  529.      change the values of variables used  in  another  procedure.   This
  530.      makes it very much easier to find program errors.
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.                                CHAPTER 3
  545.  
  546.                        LOGO PRIMITIVE PROCEDURES
  547.  
  548.  
  549.  
  550.  
  551.      This chapter describes the LOGO primitive  procedures.   These  are
  552.      routines,  or  commands,  which  are  built into LOGO.  They may be
  553.      described in LOGO by issuing the "describe" command.
  554.  
  555. LOGO PRIMITIVE PROCEDURES                                     Page 3-2
  556.  
  557.  
  558.      3.1  DEFINING USER PROCEDURES
  559.  
  560.      There are two ways to define your own procedure.   The  first  way,
  561.                    to     using   the   to  command,  is  simple  to  learn  but  limited  in
  562.                                                 edit     flexibility.  The second way,  using  the  edit  command,  is  more
  563.      complicated  to  learn,  but  makes it easy to make changes in your
  564.                       edit                                        emacs     procedures.  The edit command uses the text editing program  emacs,
  565.      just  as  you  might  use it outside of Logo to edit a document you
  566.      want to print.  Once you've learned the special editing commands in
  567.      emacs                         to     emacs, it's easy to use.  The to command makes it possible to begin
  568.                                                              emacs     programming in Logo without having learned how to  use  emacs.   It
  569.      just  lets  you  type  in  your  procedure  definition, without any
  570.      provision for correcting errors or changing the definition  of  the
  571.      procedure.   It  is  fast  and convenient for short procedures, but
  572.      limited.
  573.  
  574.          to     The to  command  is  unique,  in  Logo,  in  that  its  inputs  are
  575.                                                         evaluated     interpreted  in  a special way.  The inputs aren't evaluated:  Logo
  576.      doesn't run any procedures you name, or look up the values  of  any
  577.                                           to     variables,  before  carrying out the to command.  The example below
  578.      should make this clearer.
  579.  
  580.      to     to -- Command, special form, see below.
  581.  
  582.           This command takes a variable number of inputs.  The first  is
  583.           the name of a procedure to be defined.  The rest, if any, must
  584.           be preceded by colons, and are the names of  variables  to  be
  585.                                                                       to          used  as  inputs  to  the  procedure.  Logo responds to the to
  586.           command by printing a "greater than" sign (>) prompt, to  show
  587.           you  that  you  are  defining a procedure rather than entering
  588.           commands to be executed immediately.  You type the instruction
  589.           lines  which  make  up the definition.  When you are done with
  590.                                                 end          the definition, type the special word end on a line by itself.
  591.           For example:
  592.  
  593.           *to twoprint :thing          *to twoprint :thing
  594.           >print :thing          >print :thing
  595.           >print :thing          >print :thing
  596.           >end          >end
  597.           *          *
  598.  
  599.           This  example  shows  the  definition  of  a  procedure  named
  600.           twoprint                             thing          twoprint, which has one input, named thing.  The procedure you
  601.                                 to          are defining with the to command must not already be defined.
  602.  
  603.      edit                                        ed     edit -- Command, no inputs.  Abbreviation:  ed
  604.  
  605.           The edit command allows the  user  to  use  the  full  editing
  606.           functionality  of  the  Emacs text editor to create or correct
  607.           user procedures.  In order to be able to use this command, you
  608.           must  have  a Kept Emacs process and you must have the logical
  609.           emacs$name defined to be the name of that process.
  610.  
  611. LOGO PRIMITIVE PROCEDURES                                     Page 3-3
  612.  
  613.  
  614.           When in Emacs, the user may change  or  create  as  many  LOGO
  615.           procedures  as  is desired.  The procedures must be written to
  616.           disk files for the changes to be "seen"  by  LOGO.   All  LOGO
  617.           procedures  are contained in disk files whose names are of the
  618.           form
  619.  
  620.                procname.lg
  621.  
  622.           where "procname" is the  name  of  the  procedure.   When  the
  623.           editing  session  is  complete and all the new files have been
  624.           written out to disk, the user should execute  a  (pause-emacs)
  625.           to  return  to  LOGO.  The changes or new procedures will take
  626.           effect immediately.
  627.  
  628.      show                                        po     show -- Command, one input.  Abbreviation:  po
  629.  
  630.           The input to this command is a word or a list of words.   Each
  631.           word  must be the name of a procedure.  The command prints out
  632.           the definition(s) of the procedure(s) on your terminal.   (The
  633.                         po              printout          abbreviation  po  stands  for printout, which is the name used
  634.           for this command in some other versions of Logo.)
  635.  
  636.      pots     pots -- Command, no inputs.
  637.  
  638.           This command types at your terminal the  title  lines  of  all
  639.           procedures  you've defined, as well as the library procedures.
  640.           The name is an abbreviation for "print out titles".
  641.  
  642.      erase                                        er     erase -- Command, one input.  Abbreviation:  er
  643.  
  644.                      show          As for the show command, the input is either  a  word,  naming
  645.           one  procedure, or a list of words, naming more than one.  The
  646.           named procedures are  erased,  so  that  they  are  no  longer
  647.           defined.
  648.  
  649.  
  650. LOGO PRIMITIVE PROCEDURES                                     Page 3-4
  651.  
  652.  
  653.      3.2  MANIPULATING WORDS AND LISTS
  654.  
  655.  
  656.      There are  primitive  procedures  to  print  text  objects  on  the
  657.      terminal,  to  read  them  from  the terminal, to combine them into
  658.      larger  objects,  to  split  them  into  smaller  objects,  and  to
  659.      determine their size and nature:
  660.  
  661.      print                                        pr     print -- Command, one input.  Abbreviation:  pr
  662.  
  663.           The input, which may be a word or a list, is  printed  on  the
  664.           terminal,  followed  by  a  new line character.  (That is, the
  665.           terminal is positioned at the beginning of a  new  line  after
  666.           printing  the  object.) If the object is a list, any sub-lists
  667.           are delimited by square brackets, but the entire object is not
  668.           delimited by brackets.
  669.  
  670.      type     type -- Command, one input.
  671.  
  672.           The input, which may be a word or a list, is  printed  on  the
  673.                      without          terminal,  without  a  new  line  character.   (That  is,  the
  674.           terminal remains positioned at the end  of  the  object  after
  675.                                                       print          printing it.) Brackets are used as with the print command.
  676.  
  677.      fprint                                        fp     fprint -- Command, one input.  Abbreviation:  fp
  678.  
  679.                                          print          The input is printed as by the print command, except  that  if
  680.           it  is  a list (as opposed to a word) it is enclosed in square
  681.           brackets.  The name of the command is short for "full print".
  682.  
  683.      ftype                                        fty     ftype -- Command, one input.  Abbreviation:  fty
  684.  
  685.                                          type          The input is printed as by the type command, except that if it
  686.           is a list, it is enclosed in square brackets.
  687.  
  688.      readlist                                          rl     readlist -- Operation, no inputs.  Abbreviation:  rl
  689.  
  690.           Logo waits for a line to be typed by the user.   The  contents
  691.           of  the  line  are  made  into  a list, as though typed within
  692.           square brackets as part of  a  Logo  instruction.   (The  user
  693.           should not actually type brackets around the line, unless s/he
  694.           desires a list of one element, which is a list  itself.)  That
  695.           list is the output from the operation.
  696.  
  697.      request     request -- Operation, no inputs.
  698.  
  699.           A question mark is printed on the terminal as a prompt.   Then
  700.           Logo  waits  for  a  line  to  be  typed  by  the user, as for
  701.           readlist          readlist.
  702.  
  703.      word     word -- Operation, two inputs.
  704.  
  705.           The two inputs must be words.  The output is a word  which  is
  706.           the  concatenation  of  the  two inputs.  There is no space or
  707.           other separation of the two inputs in the output.
  708.  
  709. LOGO PRIMITIVE PROCEDURES                                     Page 3-5
  710.  
  711.  
  712.      sentence                                           se     sentence -- Operation, two inputs.  Abbreviation:  se
  713.  
  714.           The two inputs may be words or lists.  The output  is  a  list
  715.           formed  from the two inputs in this way:  if either input is a
  716.           word, that word becomes a member of the output list; if either
  717.                                  members          input  is  a list, the members of that input become members of
  718.           the output.  Here are some examples:
  719.  
  720.                first input    second input         output
  721.                "hello         "test                [hello test]
  722.                "goodbye       [cruel world]        [goodbye cruel world]
  723.                [a b]          [c d]                [a b c d]
  724.                []             "garply              [garply]
  725.  
  726.           If an input is the empty list, as in the last  example  above,
  727.           it contributes nothing to the output.
  728.  
  729.      list     list -- Operation, two inputs.
  730.  
  731.           The output is a list of two elements, namely, the two  inputs.
  732.           The inputs may be words or lists.
  733.  
  734.      fput     fput -- Operation, two inputs.
  735.  
  736.           The first input may be any Logo object; the second must  be  a
  737.           list.  The output is a list which is identical with the second
  738.           input except that it has an extra first  member,  namely,  the
  739.           first input.
  740.  
  741.      lput     lput -- Operation, two inputs.
  742.  
  743.           The first input may be any Logo object; the second must  be  a
  744.           list.  The output is a list which is identical with the second
  745.           input except that it has an extra  last  member,  namely,  the
  746.           first input.
  747.  
  748.      first                                          f     first -- Operation, one input.  Abbreviation:  f
  749.  
  750.           The input may be any non-empty Logo object.  If the input is a
  751.           list, the output is its first member.  If the input is a word,
  752.           the output is a single-letter word, namely the first letter of
  753.           the  input.   If  the input is empty (a word or list of length
  754.           zero) an error results.
  755.  
  756.      last                                          l     last -- Operation, one input.  Abbreviation:  l
  757.  
  758.           The input may be any non-empty Logo object.  If the input is a
  759.           list,  the output is its last member.  If the input is a word,
  760.           the output is a single-letter word, namely the last letter  of
  761.           the  input.   If  the input is empty (a word or list of length
  762.           zero) an error results.
  763.  
  764.      butfirst                                          bf     butfirst -- Operation, one input.  Abbreviation:  bf
  765.  
  766.           The input may be any non-empty Logo object.  If the input is a
  767.  
  768. LOGO PRIMITIVE PROCEDURES                                     Page 3-6
  769.  
  770.  
  771.           list,  the  output  is a list equal to the input list with the
  772.           first member removed.  (If the input list has only one member,
  773.                              empty list          the  output is the empty list, a list of zero members.) If the
  774.           input is a word, the output is a word equal to the input  word
  775.           with   the   first   letter  removed.   (If  the  input  is  a
  776.                                                   empty  word          single-letter word, the output is  the  empty  word.)  If  the
  777.           input is empty, an error results.
  778.  
  779.      butlast                                          bl     butlast -- Operation, one input.  Abbreviation:  bl
  780.  
  781.           The input may be any non-empty Logo object.  If the input is a
  782.           list,  the  output  is a list equal to the input list with the
  783.           last member removed.  (If the input list has only one  member,
  784.                              empty list          the  output is the empty list, a list of zero members.) If the
  785.           input is a word, the output is a word equal to the input  word
  786.           with   the   last   letter   removed.   (If  the  input  is  a
  787.                                                   empty  word          single-letter word, the output is  the  empty  word.)  If  the
  788.           input is empty, an error results.
  789.  
  790.      count     count -- Operation, one input.
  791.  
  792.           The input may be any Logo object.  If the input is a list, the
  793.           output  is  a  number  indicating the number of members in the
  794.           list.  (Note:  only top-level members are counted, not members
  795.           of members.  The count of the list
  796.  
  797.                [[This is] [a list]]
  798.  
  799.           is 2, not 4.) If the input is a word, the output is the number
  800.           of  letters  (or other characters) in the word.  Remember that
  801.           in Logo a number is just a particular kind  of  word,  so  the
  802.                       count          output from count can be manipulated like any other Logo word.
  803.  
  804.      emptyp     emptyp -- Operation (predicate), one input.
  805.  
  806.                                                                     true          The input can be any Logo object.  The output is the word true
  807.           if  the input is of length zero (i.e., it is the empty word or
  808.                                                    false          the empty list).  The output is the word false otherwise.
  809.  
  810.      wordp     wordp -- Operation (predicate), one input.
  811.  
  812.                                                                     true          The input can be any Logo object.  The output is the word true
  813.                                                             false          if  the  input is a word.  The output is the word false if the
  814.           input is a list.
  815.  
  816.      sentencep     sentencep -- Operation (predicate), one input.
  817.  
  818.                                                                     true          The input can be any Logo object.  The output is the word true
  819.           if the input is a sentence, i.e., a list of words.  The output
  820.                       false          is the word false if the input is a word, or if any member  of
  821.           the input is a list.
  822.  
  823.      is     is -- Operation (predicate), two inputs.
  824.  
  825.           The inputs can be any Logo objects.  The output  is  the  word
  826.  
  827. LOGO PRIMITIVE PROCEDURES                                     Page 3-7
  828.  
  829.  
  830.           true          true  if  the two inputs are identical.  That is, they must be
  831.           of the same type (both words or both lists),  they  must  have
  832.           the  same  count,  and  their  members  (if  lists)  or  their
  833.           characters (if words) must be identical.  The  output  is  the
  834.                 false          word  false  otherwise.   (Note:   this is an exception to the
  835.           convention that names of predicates end with the letter "p".)
  836.  
  837.      memberp     memberp -- Operation (predicate), two inputs.
  838.  
  839.           If the second input is a word, the first input must be a  word
  840.                                                                  true          of  length one (a single character), and the output is true if
  841.           and only if the first input is contained in the  second  as  a
  842.           character.  If the second input is a list, the first input can
  843.                                                 true          be any Logo object, and the output is true if and only if  the
  844.           first  input is a member of the second input.  (Note that this
  845.           is member, not subset.)
  846.  
  847.      item                                           nth     item -- Operation, two inputs.  Abbreviation:  nth
  848.  
  849.           The first input must be a positive integer less than or  equal
  850.                    count          to  the  count  of the second input.  If the second input is a
  851.           word, the output is  a  word  of  length  one  containing  the
  852.           selected character from the word.  (Items are numbered from 1,
  853.           not 0.) If the second input is  a  list,  the  output  is  the
  854.           selected member of the list.
  855.  
  856.  
  857. LOGO PRIMITIVE PROCEDURES                                     Page 3-8
  858.  
  859.  
  860.      3.3  TURTLES AND GRAPHICS
  861.  
  862.  
  863.      An important part  of  the  Logo  environment  is  a  rich  set  of
  864.      applications  to  which  the  computer  can  be directed.  The most
  865.                            turtle geometry     important of these is turtle geometry, a way of describing paths of
  866.      motion  in  a  plane  which is well-suited to computer programming.
  867.      There are two ways to use the turtle procedures.   First,  you  can
  868.                 floor turtle     control  a floor turtle, a small robot which can move one the floor
  869.      or on a table under  computer  control.   Second,  you  can  use  a
  870.      display  turtle     display  turtle  to  draw  pictures  on the TV screen of a graphics
  871.      terminal.
  872.  
  873.      Each computer center has a different variety of  graphics  hardware
  874.      available.   Floor turtles are very different from display turtles,
  875.      but  also   each   kind   of   display   terminal   has   different
  876.      characteristics.   For  example, some terminals can draw in several
  877.      colors; others  can't.   The  following  descriptions  of  graphics
  878.      primitives  explain  the  "best"  case  for  each  one  and mention
  879.      restrictions on some graphics devices.
  880.  
  881.      The floor turtle can draw pictures on paper, because it has  a  pen
  882.      attached to its "belly":  the underside of the turtle.  Since it is
  883.      a mechanical device, however, it is not very precise; the  pictures
  884.      you  get  may  not  be exactly like what your program specifies.  A
  885.      more interesting way to use the floor turtle is to  take  advantage
  886.               touch sensors     of  its  touch sensors.  Switches under the turtle's dome allow the
  887.      computer to know when the turtle bumps into an obstacle.   You  can
  888.      use  this  information to write programs to get around obstacles or
  889.      to follow a maze.
  890.  
  891.      The display turtle lives on the surface of a  TV  screen.   It  can
  892.      draw  pictures  more precisely than the floor turtle, since it does
  893.      not measure distances and angles mechanically.  It is  also  faster
  894.      than  the  floor  turtle.   When using the display turtle, remember
  895.      that it interprets  commands  relative  to  its  own  position  and
  896.                                                                left     direction,  just  as  the floor turtle does.  The command left, for
  897.      example, turns the turtle to its own left, which may or may not  be
  898.      toward the left side of the TV screen.
  899.  
  900.      turtle                                        tur     turtle -- Command, one input.  Abbreviation:  tur
  901.  
  902.           The input is the name of a turtle.  You can only  control  one
  903.           turtle at a time, so using this command a second time releases
  904.           the turtle previously selected.  The names  of  floor  turtles
  905.                            0     1          are numbers like 0 and 1.  If you are using a graphics display
  906.           terminal (not just a text display trminal),  you  can  control
  907.                                                        display          the   display  turtle  by  using  the  word  display  (or  the
  908.                        dpy          abbreviation dpy) as the turtle name.   (As  usual,  the  word
  909.           must  be  preceded by a quotation mark.) If you use a graphics
  910.           primitive without selecting a turtle, Logo  assumes  that  you
  911.           want  to  use the display turtle.  But once you select a floor
  912.                                turtle "display          turtle, you must say turtle "display explicitly to  switch  to
  913.           the display.
  914.  
  915. LOGO PRIMITIVE PROCEDURES                                     Page 3-9
  916.  
  917.  
  918.                    off                 turtle          The word off as input to the turtle command releases  a  floor
  919.           turtle,  if you have one, or turns off the graphics display if
  920.           you have been using the display  turtle.   This  also  happens
  921.           when you leave Logo.
  922.  
  923.      forward                                        fd     forward -- Command, one input.  Abbreviation:  fd
  924.  
  925.           The input is a number, the distance you would like the  turtle
  926.           to  move.  For a floor turtle, the unit of distance is however
  927.           far the turtle can travel  in  1/30  second.   For  a  display
  928.           turtle, the unit is one dot on the TV screen.  (Note:  on some
  929.           displays, one dot horizontally may not be the same  length  as
  930.                                        setscrunch          one  dot  vertically.   The  setscrunch  command allows you to
  931.           control the relative sizes so that squares come  out  square.)
  932.           The turtle moves in whatever direction it is pointing when you
  933.           use the command.
  934.  
  935.      back                                        bk     back -- Command, one input.  Abbreviation:  bk
  936.  
  937.                                                                  forward          The input is a number, a distance to move, as in  the  forward
  938.           command.   The  difference  is that the turtle moves backward,
  939.           i.e., in the  direction  exactly  opposite  to  the  way  it's
  940.           pointing.
  941.  
  942.      left                                        lt     left -- Command, one input.  Abbreviation:  lt
  943.  
  944.           The input is a number, the number of degrees of angle  through
  945.           which  the  turtle should turn counterclockwise.  This command
  946.                               position          does not change the position of the  turtle,  but  merely  its
  947.           heading          heading  (the direction in which it points).  The turn will be
  948.           only approximately correct for the floor  turtle,  because  of
  949.           mechanical  errors.  For the display turtle, the angle will be
  950.           perfectly reproducible, although it may not look  quite  right
  951.           on  the  screen  because  of  the  difference  in size between
  952.           horizontal and vertical dots.  Nevertheless, a display  turtle
  953.           program  will  work  in  the  sense  that  when  the turtle is
  954.           supposed to return to its starting point, it will do so.
  955.  
  956.      right                                        rt     right -- Command, one input.  Abbreviation:  rt
  957.  
  958.           The input is a number; the turtle turns through the  specified
  959.           number of degrees clockwise.
  960.  
  961.      penup                                        pu     penup -- Command, no inputs.  Abbreviation:  pu
  962.  
  963.           This command tells the turtle to raise its pen from the paper,
  964.           so  that it does not leave a trace when it moves.  In the case
  965.           of the display turtle,  there  is  no  physical  pen  to  move
  966.                                                          forward    back          mechanically, but the effect is the same:  any forward or back
  967.           commands after this point do  not  draw  a  line.   The  floor
  968.           turtle  starts with its pen up; the display turtle starts with
  969.           its pen down.  Note:  the floor turtle will not  move  on  the
  970.           carpet correctly with its pen down; put it on a smooth surface
  971.           if you want to draw pictures.
  972.  
  973. LOGO PRIMITIVE PROCEDURES                                    Page 3-10
  974.  
  975.  
  976.      pendown                                        pd     pendown -- Command, no inputs.  Abbreviation:  pd
  977.  
  978.           This command tells the turtle to lower its pen, so that  later
  979.           commands will draw lines when the turtle moves.
  980.  
  981.      penerase                                        pe     penerase -- Command, no inputs.  Abbreviation:  pe
  982.  
  983.           This command tells the turtle to "lower its eraser",  so  that
  984.           lines  previously  drawn  will  be erased when retraced by the
  985.           turtle.  It only works with the display turtle.  The  commands
  986.           penup    pendown    penerase         penreverse          penup,   pendown,   penerase,   and  penreverse  are  mutually
  987.           exclusive; whichever was most recently used is the  one  which
  988.           affects   the   turtle.    (Graphics  terminals  which  cannot
  989.           selectively erase lines,  such  as  Tektronix  displays,  will
  990.                 penerase    pendown          treat penerase as pendown.)
  991.  
  992.      penreverse                                        px     penreverse -- Command, no inputs.  Abbreviation:  px
  993.  
  994.           This command tells the display turtle to lower its  "reversing
  995.           pen";  thereafter,  when  the  turtle  moves,  it turns on any
  996.           points which were off, and turns off any points which were on.
  997.                          penup   pendown   penerase       penreverse          The  commands  penup,  pendown,  penerase,  and penreverse are
  998.           mutually exclusive; whichever was most recently  used  is  the
  999.           one  which  affects  the  turtle.   (Note:  Graphics terminals
  1000.                                                              pendown          which cannot penreverse will treat this command as pendown.)
  1001.  
  1002.      penmode     penmode -- Operation, no inputs.
  1003.  
  1004.           This operation applies to the floor or the display turtle.  It
  1005.                                          penup   pendown   penerase          outputs   one  of  the  words  penup,  pendown,  penerase,  or
  1006.           penreverse          penreverse, depending on the current  state  of  the  turtle's
  1007.           pen.
  1008.  
  1009.      lampon                                        lon     lampon -- Command, no inputs.  Abbreviation:  lon
  1010.  
  1011.           This command applies only to the floor turtle; it turns on the
  1012.           headlamps on the front of the turtle.
  1013.  
  1014.      lampoff                                        loff     lampoff -- Command, no inputs.  Abbreviation:  loff
  1015.  
  1016.           This command turns off the floor turtle's headlamps.
  1017.  
  1018.      hitoot                                        hit     hitoot -- Command, one input.  Abbreviation:  hit
  1019.  
  1020.           This command applies only to the floor turtle.  It sounds  the
  1021.           turtle's  horn at the higher of its two pitches.  The input is
  1022.           a number which indicates the number of quarter-seconds to toot
  1023.           the  horn.  Note:  large numbers are likely to lead to violent
  1024.           behavior on the part of other computer users.
  1025.  
  1026.      lotoot                                        lot     lotoot -- Command, one input.  Abbreviation:  lot
  1027.  
  1028.           This command sounds the floor turtle's horn at  the  lower  of
  1029.           its two pitches.  The input is the duration of the toot.
  1030.  
  1031. LOGO PRIMITIVE PROCEDURES                                    Page 3-11
  1032.  
  1033.  
  1034.      ftouch                                                      fto     ftouch -- Operation (predicate), no inputs.  Abbreviation:  fto
  1035.  
  1036.           This operation can be used only with the floor turtle.  It has
  1037.                                       true          as  its  output  the  word  true if the front of the turtle is
  1038.                                                           false          touching an obstacle; otherwise it has the word false  as  its
  1039.           output.
  1040.  
  1041.      btouch                                                      bto     btouch -- Operation (predicate), no inputs.  Abbreviation:  bto
  1042.  
  1043.           This operation can be used only with the floor turtle.  It has
  1044.                                       true          as  its  output  the  word  true  if the back of the turtle is
  1045.                                                           false          touching an obstacle; otherwise it has the word false  as  its
  1046.           output.
  1047.  
  1048.      ltouch                                                      lto     ltouch -- Operation (predicate), no inputs.  Abbreviation:  lto
  1049.  
  1050.           This operation can be used only with the floor turtle.  It has
  1051.                                   true          as  its output the word true if the left side of the turtle is
  1052.                                                           false          touching an obstacle; otherwise it has the word false  as  its
  1053.           output.
  1054.  
  1055.      rtouch                                                      rto     rtouch -- Operation (predicate), no inputs.  Abbreviation:  rto
  1056.  
  1057.           This operation can be used only with the floor turtle.  It has
  1058.                                  true          as its output the word true if the right side of the turtle is
  1059.                                                           false          touching an obstacle; otherwise it has the word false  as  its
  1060.           output.
  1061.  
  1062.      clearscreen                                        cs     clearscreen -- Command, no inputs.  Abbreviation:  cs
  1063.  
  1064.           This command applies only to the display  turtle.   It  erases
  1065.           everything  on  the  TV screen, and restores the turtle to its
  1066.           initial position and heading (center  of  the  screen,  facing
  1067.           toward the top edge).
  1068.  
  1069.      wipeclean                                        clean     wipeclean -- Command, no inputs.  Abbreviation:  clean
  1070.  
  1071.           This command applies only to the display  turtle.   It  erases
  1072.           everything  on the TV screen, but does not change the turtle's
  1073.           position or heading.
  1074.  
  1075.      fullscreen                                        full     fullscreen -- Command, no inputs.  Abbreviation:  full
  1076.  
  1077.           This command applies only to the  Atari  display  turtle.   It
  1078.           eliminates  the  use of the bottom four lines of the screen to
  1079.           display the commands you type; instead, the entire  screen  is
  1080.           available  to  show the picture drawn by the turtle.  However,
  1081.           you can no longer see what you're typing.  The command may  be
  1082.           used  after the picture is already drawn; the part "hidden" by
  1083.           the text at the bottom of the screen will become visible.   On
  1084.                             fullscreen       splitscreen          other  displays,  fullscreen  and  splitscreen are equivalent;
  1085.           they make the entire screen available for graphics,  and  text
  1086.           appears  on the bottom line (Gigis) or superimposed (ADMs), or
  1087.           somewhere.
  1088.  
  1089. LOGO PRIMITIVE PROCEDURES                                    Page 3-12
  1090.  
  1091.  
  1092.      splitscreen                                        split     splitscreen -- Command, no inputs.  Abbreviation:  split
  1093.  
  1094.           This command applies only to the  Atari  display  turtle.   It
  1095.           restores  the normal text display at the bottom of the screen,
  1096.                                     full          undoing the effect of the full command.   On  other  displays,
  1097.           fullscreen       splitscreen          fullscreen  and  splitscreen  are  equivalent;  they  make the
  1098.           entire screen available for graphics, with  text  superimposed
  1099.           in a display-dependent area.
  1100.  
  1101.      textscreen                                        text     textscreen -- Command, no inputs.  Abbreviation:  text
  1102.  
  1103.           This  command  applies  only  to  the  display   turtle.    It
  1104.           temporarily removes the turtle display from the screen, making
  1105.           the entire screen available for text  display.   The  commands
  1106.           fullscreen      splitscreen          fullscreen  and splitscreen will restore the graphics display.
  1107.           Note:  On the Atari display, the  picture  on  the  screen  is
  1108.                                                           fullscreen          remembered,   so   that  when  you  return  to  fullscreen  or
  1109.           splitscreen          splitscreen mode, the picture returns to the screen.  On other
  1110.           displays, the picture is forgotten, and you return to an empty
  1111.           graphics screen.
  1112.  
  1113.      hideturtle                                        ht     hideturtle -- Command, no inputs.  Abbreviation:  ht
  1114.  
  1115.           This command applies only to the display  turtle.   It  erases
  1116.           the display of the turtle itself from the screen, so that only
  1117.           the lines drawn  when  the  turtle  moves  are  visible.   The
  1118.           display  is  faster  when  the turtle is hidden (only slightly
  1119.           faster on the Atari, but  much  faster  on  other  terminals).
  1120.           Also,  once a graphics program is debugged, it may be prettier
  1121.           to watch without the turtle visible.  (Note:  On the Tektronix
  1122.           display,  the  turtle  is  never visible, because the terminal
  1123.           cannot erase selectively.)
  1124.  
  1125.      showturtle                                        st     showturtle -- Command, no inputs.  Abbreviation:  st
  1126.  
  1127.           This command applies only to the display turtle.  It  restores
  1128.                                                   hideturtle          the  display  of  the turtle, after the hideturtle command has
  1129.           been used.  (Note:  On the Tektronix display,  the  turtle  is
  1130.           never visible.)
  1131.  
  1132.      shownp     shownp -- Operation (predicate), no inputs.
  1133.  
  1134.           This predicate applies only to the display turtle.  It outputs
  1135.                    true                                            false          the word true if the turtle is visible on the TV screen, false
  1136.           otherwise.
  1137.  
  1138.      pencolor                                        penc     pencolor -- Command, one input.  Abbreviation:  penc
  1139.  
  1140.           This command applies only to the display turtle.   Its  effect
  1141.           is  different  depending on how each type of terminal supports
  1142.           color.  For the Atari, the input must be an integer between  0
  1143.           and  6.   An  input  of  0 enters black-and-white display mode
  1144.           (which is the turtle's initial mode), in which  lines  are  as
  1145.           thin  as possible but there is no control of color.  Any other
  1146.           input selects color mode, in which lines are twice  as  thick,
  1147.  
  1148. LOGO PRIMITIVE PROCEDURES                                    Page 3-13
  1149.  
  1150.  
  1151.           so the effective size of the screen is smaller, but colors can
  1152.           be used.  There are, in color mode, three possible pen colors,
  1153.           numbered  1  to  3.   There  are 256 possible colors, but only
  1154.                                                     setcolor          three can be on the screen at a time; the setcolor command  is
  1155.           used  to decide which pen draws in which actual color.  If the
  1156.           input is 4, 5, or 6, the color is that of  pen  1,  2,  or  3,
  1157.           respectively,  but  lines  are drawn in "fill mode":  for each
  1158.           point inked, all points to its right are also  inked  until  a
  1159.           point  is reached which was already inked.  On the Gigi, there
  1160.           is only one mode, and there is no loss of resolution in  using
  1161.           color.   The  input  must be between 0 and 7; 0 means black, 7
  1162.           means white.  The ADM, Tektronix, and Sun displays do not have
  1163.           multi-color drawing.
  1164.  
  1165.      setcolor                                         setc     setcolor -- Command, two inputs.  Abbreviation:  setc
  1166.  
  1167.           This command applies only to the Atari  display  turtle.   The
  1168.           first  input must be an integer between 0 and 3.  If the input
  1169.           is nonzero, the second input specifies the color for  the  pen
  1170.           selected  by the first input.  If the first input is zero, the
  1171.           second input specifies the  background  color  for  the  color
  1172.           graphics  display.   The  second  input  is  either an integer
  1173.           between 0 and 15, which is a color number, or a  list  of  two
  1174.           integers,  in  which  case the first is a color number and the
  1175.           second is an intensity number, an integer between 0 and 7.
  1176.  
  1177.      setxy     setxy -- Command, two inputs.
  1178.  
  1179.           The two inputs must be numbers.  The turtle is  moved  to  the
  1180.           point  on  the  screen  whose x (horizontal) coordinate is the
  1181.           first input, and whose y (vertical) coordinate is  the  second
  1182.           input.  The center of the screen, where the turtle starts, has
  1183.           both coordinates zero.  If the pen is down, this command draws
  1184.           a line.  This command applies only to the display turtle.
  1185.  
  1186.      setheading                                        seth     setheading -- Command, one input.  Abbreviation:  seth
  1187.  
  1188.           The input must be a number.  The turtle's heading  is  set  to
  1189.           the  input, taken in degrees.  Zero points straight up, as the
  1190.           turtle starts out; positive headings are clockwise from  zero.
  1191.           This command applies only to the display turtle.
  1192.  
  1193.      towardsxy     towardsxy -- Operation, two inputs.
  1194.  
  1195.           This operation applies only to the display  turtle.   The  two
  1196.           inputs must be numbers, which are the x and y coordinates of a
  1197.           point on the TV screen.  The output is a number which  is  the
  1198.           heading  to  which  the  turtle must be set, in order to point
  1199.           towards that point from its  current  position.   Note:   this
  1200.           operation does not actually move or turn the turtle.  You must
  1201.                                  setheading          use it as the input to setheading if that is what you want.
  1202.  
  1203.      xcor     xcor -- Operation, no inputs.
  1204.  
  1205.           The output is the turtle's current x (horizontal)  coordinate.
  1206.  
  1207. LOGO PRIMITIVE PROCEDURES                                    Page 3-14
  1208.  
  1209.  
  1210.           The operation works only with the display turtle.
  1211.  
  1212.      ycor     ycor -- Operation, no inputs.
  1213.  
  1214.           The output is the turtle's current  y  (vertical)  coordinate.
  1215.           This operation works only with the display turtle.
  1216.  
  1217.      heading     heading -- Operation, no inputs.
  1218.  
  1219.           The output is the turtle's current heading in  degrees.   This
  1220.           operation works only with the display turtle.
  1221.  
  1222.      getpen     getpen -- Operation, no inputs.
  1223.  
  1224.           The output is the turtle's  current  pen  color,  or  (on  the
  1225.           Atari)  zero if in black-and-white mode.  This operation works
  1226.           only with the display turtle.
  1227.  
  1228.      setscrunch                                        setscrun     setscrunch -- Command, one input.  Abbreviation:  setscrun
  1229.  
  1230.           This command is used only for display turtles.  The input must
  1231.           be  a  number.   The  vertical  component  of turtle motion is
  1232.           multiplied by this number before each  motion  is  taken.   If
  1233.           squares  come out too wide on your screen, you should increase
  1234.           the number; if too tall, you should  decrease  it.   (You  can
  1235.                     setscrunch          also  use setscrunch to deform the turtle's motion on purpose,
  1236.           so for example a circle program will draw an ellipse instead.)
  1237.           The  initial  scrunch  value  depends  on the terminal you are
  1238.           using:  for the Atari and the Gigi, it  is  around  0.8  (your
  1239.           particular computer center will adjust this for the particular
  1240.           TV monitors you use), but for the ADM, Tektronix, and Sun,  it
  1241.           is  1.0  because  these  terminals display the same size steps
  1242.           horizontally and vertically.
  1243.  
  1244.      scrunch     scrunch -- Operation, no inputs.
  1245.  
  1246.           This operation is used only for display turtles.  It outputs a
  1247.           number, which is the scrunch factor (or aspect ratio) by which
  1248.           vertical motion is multiplied before it  is  displayed.   This
  1249.                                       setscrunch          number is changed using the setscrunch command.
  1250.  
  1251.  
  1252. LOGO PRIMITIVE PROCEDURES                                    Page 3-15
  1253.  
  1254.  
  1255.      3.4  ARITHMETIC
  1256.  
  1257.  
  1258.      Several procedures  are  available  for  arithmetic  operations  on
  1259.      numbers.   In  all  cases,  the  inputs to these procedures must be
  1260.      numbers,  except  as  otherwise   indicated   in   the   individual
  1261.      descriptions.
  1262.  
  1263.      In general, procedures are used in Logo by typing first the name of
  1264.      the  procedure,  then  its  inputs.   This  is  true  of arithmetic
  1265.      procedures also, e.g.
  1266.  
  1267.           sum 3 2
  1268.  
  1269.      However, for some arithmetic operations, Logo also  recognizes  the
  1270.                       infix     more traditional infix notation, with the operation between the two
  1271.      inputs:
  1272.  
  1273.           3 + 2
  1274.  
  1275.      Be warned, though, that the use of infix forms makes  it  difficult
  1276.      for  Logo  to  know how to group operations, unless parentheses are
  1277.      used.  If you stick to the standard (in Logo) prefix notation,  the
  1278.      grouping  is  always  unambiguous.   For  example, the first two of
  1279.      these three instructions are equivalent, but the third is not:
  1280.  
  1281.           if equalp count "hello 5 [print "Yes.]
  1282.  
  1283.           if (count "hello) = 5 [print "Yes.]
  1284.  
  1285.           if count "hello = 5 [print "Yes.]
  1286.  
  1287.      The reason for the error message produced  by  the  last  of  those
  1288.      three instructions is that Logo interprets it as
  1289.  
  1290.           if count equalp "hello 5 [print "Yes.]
  1291.  
  1292.                                                            hello     That is, the equality test is done first, on the word hello itself,
  1293.                                            hello     rather than first taking the count of hello as was intended.
  1294.  
  1295.      sum                                    +     sum -- Operation, two inputs.  Infix:  +
  1296.  
  1297.           The output of this procedure is the sum of the two inputs.
  1298.  
  1299.      difference                                           diff         -     difference -- Operation, two inputs.  Abbreviation:  diff Infix:  -
  1300.  
  1301.           The output of this procedure is  the  difference  of  the  two
  1302.           inputs.
  1303.  
  1304.      product     product -- Operation, two inputs.  Infix:
  1305.  
  1306.           T          The output of this procedure is the product of the two inputs.
  1307.  
  1308.      quotient                                    /     quotient -- Operation, two inputs.  Infix:  /
  1309.  
  1310. LOGO PRIMITIVE PROCEDURES                                    Page 3-16
  1311.  
  1312.  
  1313.           The output of this  procedure  is  the  quotient  of  the  two
  1314.           inputs.   If  both  inputs are integers, the output is also an
  1315.           integer; the remainder of the division  is  lost.   If  either
  1316.           input is not an integer, the quotient can include a fractional
  1317.           part.  Therefore, these two are not the same:
  1318.  
  1319.                quotient 2 3 quotient 2.0 3
  1320.  
  1321.  
  1322.      remainder                                           mod         \     remainder -- Operation, two inputs.  Abbreviation:  mod Infix:  \
  1323.  
  1324.           The inputs to this procedure must be integers.  The output  is
  1325.           also  an  integer,  and is the remainder of dividing the first
  1326.           input by the second.
  1327.  
  1328.      maximum                                           max     maximum -- Operation, two inputs.  Abbreviation:  max
  1329.  
  1330.           The output of this procedure is equal to whichever of the  two
  1331.           inputs is numerically greater.
  1332.  
  1333.      minimum                                           min     minimum -- Operation, two inputs.  Abbreviation:  min
  1334.  
  1335.           The output of this procedure is equal to whichever of the  two
  1336.           inputs is numerically smaller.
  1337.  
  1338.      greaterp                                                >     greaterp -- Operation (predicate), two inputs.  Infix:  >
  1339.  
  1340.                                                     true          The output of this procedure is the word  true  if  the  first
  1341.           input  is  numerically strictly greater than the second input.
  1342.                                            false          Otherwise the output is the word false.
  1343.  
  1344.      lessp                                                <     lessp -- Operation (predicate), two inputs.  Infix:  <
  1345.  
  1346.                                                     true          The output of this procedure is the word  true  if  the  first
  1347.           input  is  numerically  strictly  less  than the second input.
  1348.                                            false          Otherwise the output is the word false.
  1349.  
  1350.      equalp                                                =     equalp -- Operation (predicate), two inputs.  Infix:  =
  1351.  
  1352.           The two inputs to this procedure may be any Logo objects.   If
  1353.                                                         true          they are numbers, then the output is the word true if they are
  1354.                              false          numerically equal, false if they are numerically unequal.   If
  1355.           either  input  is not a number, then the output is the same as
  1356.                             is           true          for the procedure is:  it  is  true  if  the  two  inputs  are
  1357.                       false                                    2     2.0          identical,  false  if not.  For example, the numbers 2 and 2.0
  1358.           are numerically equal, but not identical.
  1359.  
  1360.      numberp     numberp -- Operation (predicate), one input.
  1361.  
  1362.                                                                     true          The input may be any Logo object.  The output is the word true
  1363.                                     false          if the input is a number, false if not.
  1364.  
  1365.      zerop     zerop -- Operation (predicate), one input.
  1366.  
  1367.                                                                 true          The input must be a number.  The output is the  word  true  if
  1368.  
  1369. LOGO PRIMITIVE PROCEDURES                                    Page 3-17
  1370.  
  1371.  
  1372.                                                   false          the input is numerically equal to zero, false otherwise.
  1373.  
  1374.      random     random -- Operation, no inputs.
  1375.  
  1376.           The output from this procedure is an integer between 0 and  9,
  1377.           i.e.,  a  single  digit.  It is chosen randomly, so the output
  1378.           may be different each time the procedure is used.
  1379.  
  1380.      rnd     rnd -- Operation, one input.
  1381.  
  1382.           The input must  be  a  positive  integer.   The  output  is  a
  1383.           randomly  selected  integer  between  0  and one less than the
  1384.           input.
  1385.  
  1386.      sqrt     sqrt -- Operation, one input.
  1387.  
  1388.           The input must be a nonnegative number.   The  output  is  its
  1389.           square root.
  1390.  
  1391.      pow     pow -- Operation, two inputs.
  1392.  
  1393.           The inputs must be numbers.  If the  first  is  negative,  the
  1394.           second  must  be  an  integer.  The output is the first number
  1395.           raised to the power of the second input.
  1396.  
  1397.      sin     sin -- Operation, one input.
  1398.  
  1399.           The input must be numeric.  The output  is  the  sine  of  the
  1400.           input, taken in degrees, not radians.
  1401.  
  1402.      cos     cos -- Operation, one input.
  1403.  
  1404.           The input must be numeric.  The output is the  cosine  of  the
  1405.           input, taken in degrees, not radians.
  1406.  
  1407.      arctan                                          atan     arctan -- Operation, one input.  Abbreviation:  atan
  1408.  
  1409.           The input must be numeric.  The output is the  arctangent,  in
  1410.           degrees, of the input.
  1411.  
  1412.  
  1413. LOGO PRIMITIVE PROCEDURES                                    Page 3-18
  1414.  
  1415.  
  1416.      3.5  CONDITIONAL EXECUTION
  1417.  
  1418.  
  1419.                           wordp     The predicates (like wordp) which we've mentioned above can be used
  1420.      to  carry  out  some command only if a condition is met.  The basic
  1421.                                 if     command for the purpose is if:
  1422.  
  1423.      if     if -- Command or operation, two or three inputs.
  1424.  
  1425.                                  if          The first input to the if procedure must be  either  the  word
  1426.           true                false          true  or  the  word false.  Typically, it is the output from a
  1427.           predicate.  The second and (optional) third inputs  are  lists
  1428.           containing instruction lines.  The second input is executed if
  1429.                              true          the first input is true.  The third input, if any, is executed
  1430.                                 false          if the first input is false:
  1431.  
  1432.           to greet :person          to greet :person
  1433.           if equalp :person [Ronald Reagan] [print [Hi, turkey!]] \          if equalp :person [Ronald Reagan] [print [Hi, turkey!]] \
  1434.                 [print sentence "Hi, :person]                [print sentence "Hi, :person]
  1435.           end          end
  1436.  
  1437.                                               if          In that example, the first input to if is the output from  the
  1438.           expression
  1439.           equalp :person [Ronald Reagan]          equalp :person [Ronald Reagan].
  1440.  
  1441.               if          The if procedure can be used  as  an  operation,  producing  a
  1442.           value.  In this case, the third input is required:
  1443.  
  1444.           print if equalp :person "Reagan ["Loser] ["Winner]          print if equalp :person "Reagan ["Loser] ["Winner]
  1445.  
  1446.      test     test -- Command, one input.
  1447.  
  1448.                                        true                 false          The input must be the  word  true  or  the  word  false.   The
  1449.                                                                iftrue          command  remembers  its  input  for  use  in a later iftrue or
  1450.           iffalse                                     if          iffalse command.  This is an alternative to if which is useful
  1451.           if several instructions are to be made conditional on the same
  1452.           condition.  The remembered truth value is local to the current
  1453.           procedure, if any.
  1454.  
  1455.      iftrue                                        ift     iftrue -- Command, one input.  Abbreviation:  ift
  1456.  
  1457.           The input must be an instruction list.  It is run if the  most
  1458.                  test                 true          recent test command saved a true value.
  1459.  
  1460.      iffalse                                        iff     iffalse -- Command, one input.  Abbreviation:  iff
  1461.  
  1462.           The input must be an instruction list.  It is run if the  most
  1463.                  test                 false          recent test command saved a false value.
  1464.  
  1465.      both                                                       and     both -- Operation (predicate), two inputs.  Abbreviation:  and
  1466.  
  1467.                                              true    false          The two inputs must both be either true or false.  The  output
  1468.               true                         true          is  true  if  both  inputs  are  true; otherwise the output is
  1469.           false          false.
  1470.  
  1471. LOGO PRIMITIVE PROCEDURES                                    Page 3-19
  1472.  
  1473.  
  1474.      either                                                       or     either -- Operation (predicate), two inputs.  Abbreviation:  or
  1475.  
  1476.                                         true    false          The two inputs must be either true or false.   The  output  is
  1477.           true                                       true          true  if  at  least  one  of the inputs is true; otherwise the
  1478.                     false          output is false.
  1479.  
  1480.      not     not -- Operation (predicate), one input.
  1481.  
  1482.                                    true    false                 true          The input must be either true or false.  The output is true if
  1483.                        false          the input is false, and vice versa.
  1484.  
  1485.  
  1486. LOGO PRIMITIVE PROCEDURES                                    Page 3-20
  1487.  
  1488.  
  1489.      3.6  FILE INPUT AND OUTPUT
  1490.  
  1491.  
  1492.      In the VMS operating system, there are  two  steps  in  reading  or
  1493.                                              opened     writing files:  first, the file must be opened, thereby associating
  1494.      a "file descriptor" (an integer) with the file  name;  second,  the
  1495.      file  descriptor is used to specify the file for each read or write
  1496.      operation.  Logo has primitive procedures for each of these steps.
  1497.  
  1498.      openread                                          openr     openread -- Operation, one input.  Abbreviation:  openr
  1499.  
  1500.           The input to this procedure is a word, which  must  be  a  VMS
  1501.           filename.  It can contain slashes to indicate directory names.
  1502.           If the file can be opened for reading,  the  output  from  the
  1503.           procedure  is  a  file descriptor, which should be stored in a
  1504.           variable for use in reading the file.  If the file  cannot  be
  1505.           opened, an error results.
  1506.  
  1507.      fileread                                          fird     fileread -- Operation, one input.  Abbreviation:  fird
  1508.  
  1509.           The input must be a  file  descriptor,  previously  output  by
  1510.           openread          openread.   The  procedure  reads one line from the file.  The
  1511.           output is the line, in the form of  a  list.   (That  is,  the
  1512.           output is the file line as if enclosed in square brackets in a
  1513.           program.) If the end of the file has been reached, the  output
  1514.           is  the  empty  word.   If  the  file line contains mismatched
  1515.           brackets, trouble may result.
  1516.  
  1517.      fileword                                          fiwd     fileword -- Operation, one input.  Abbreviation:  fiwd
  1518.  
  1519.           The input must be a file descriptor, open  for  reading.   The
  1520.           procedure  reads  one  line from the file.  The output is that
  1521.           line, in the form of  a  single  word,  including  spaces  and
  1522.           punctuation  characters.   If  the  end  of  the file has been
  1523.           reached, the output is the empty list.
  1524.  
  1525.      openwrite                                          openw     openwrite -- Operation, one input.  Abbreviation:  openw
  1526.  
  1527.           The input must be a VMS filename.   The  file  is  opened  for
  1528.           writing  (replacing any previous version), if allowed, and the
  1529.           output is a file descriptor, for use by file printing commands
  1530.           below.  If the file cannot be opened, an error results.
  1531.  
  1532.      fileprint                                        fip     fileprint -- Command, two inputs.  Abbreviation: fip
  1533.      filetype                                        fity     filetype -- Command, two inputs.  Abbreviation: fity
  1534.      filefprint                                        fifp     filefprint -- Command, two inputs.  Abbreviation: fifp
  1535.      fileftype                                        fifty     fileftype -- Command, two inputs.  Abbreviation: fifty
  1536.  
  1537.           The first input must be a file descriptor previously output by
  1538.           openwrite          openwrite.  The second input is any object.  The second  input
  1539.           is  printed  (typed,  fprinted,   ftyped)   into   the   file.
  1540.  
  1541.      close     close -- Command, one input.
  1542.  
  1543.           The input must be a file  descriptor.   The  file  is  closed.
  1544.  
  1545. LOGO PRIMITIVE PROCEDURES                                    Page 3-21
  1546.  
  1547.  
  1548.           This                                                      must
  1549.           be done when you've finished  reading  or  writing  the  file.
  1550.  
  1551.           Sample                                                program:
  1552.  
  1553.           make "fd openwrite "outfile          make "fd openwrite "outfile
  1554.           fileprint :fd "Hello.          fileprint :fd "Hello.
  1555.           close :fd          close :fd
  1556.  
  1557.                                           outfile          This will create a file  named  outfile  containing  the  word
  1558.           Hello.          Hello.
  1559.  
  1560.  
  1561. LOGO PRIMITIVE PROCEDURES                                    Page 3-22
  1562.  
  1563.  
  1564.      3.7  PROCEDURE EXIT
  1565.  
  1566.  
  1567.      A procedure written by a user, in Logo, can  be  a  command  or  an
  1568.      operation.   If it is an operation, you must, in the procedure, say
  1569.      what its output should be.  If it is a command, it can simply  stop
  1570.      at  the  end  of  the procedure, or you can explicitly make it stop
  1571.      before the end.
  1572.  
  1573.      output                                        op     output -- Command, one input.  Abbreviation:  op
  1574.  
  1575.           This command is used in a user procedure which is meant to  be
  1576.           an  operation.   The  input to this command becomes the output
  1577.           from the user procedure.  Please don't be confused by the fact
  1578.                                                                   output          that  the  user  procedure  is  an operation, while the output
  1579.           primitive procedure is  a  command  used  in  that  procedure.
  1580.           Example:
  1581.  
  1582.           to nickname :person          to nickname :person
  1583.           if equalp :person [Peter Parker] [output "Spiderman]          if equalp :person [Peter Parker] [output "Spiderman]
  1584.           if equalp :person [Lamont Cranston] [output "Shadow]          if equalp :person [Lamont Cranston] [output "Shadow]
  1585.           output first :person          output first :person
  1586.           end          end
  1587.  
  1588.      stop     stop -- Command, no inputs.
  1589.  
  1590.           This command is used in user procedures which are meant to  be
  1591.           commands.   It  stops  the user procedure.  (Note that it does
  1592.           not stop all running procedures.  If  user  procedure  A  runs
  1593.                                   stop          user  procedure  B,  a  stop command in procedure B returns to
  1594.           procedure A, which continues after the point where procedure B
  1595.           was invoked.)
  1596.  
  1597.      toplevel                                        top     toplevel -- Command, no inputs.  Abbreviation:  top
  1598.  
  1599.           This command stops all running procedures.  The  user  at  the
  1600.           terminal  is  prompted  to  type another command.  This can be
  1601.           used when a user procedure discovers some error condition  and
  1602.           wants to abort the entire program, for example.
  1603.  
  1604.  
  1605. LOGO PRIMITIVE PROCEDURES                                    Page 3-23
  1606.  
  1607.  
  1608.      3.8  PROPERTY LISTS
  1609.  
  1610.  
  1611.      It is possible to associate with any name a list  of  "properties".
  1612.      A  property  list contains property names and property values.  For
  1613.      example:
  1614.  
  1615.  
  1616.           pprop "bh "firstname "Brian          pprop "bh "firstname "Brian
  1617.           pprop "bh "lastname "Harvey          pprop "bh "lastname "Harvey
  1618.  
  1619.      The form of a property list is
  1620.  
  1621.           [name1 val1 name2 val2 name3 val3]
  1622.  
  1623.      Although this data structure could  be  created  using  other  Logo
  1624.      primitives,  special  property list primitives are provided because
  1625.      they are faster.  The property lists do not share storage with Logo
  1626.      variables,  so  you  can  change  the value of any property without
  1627.      having to recopy the entire property list as you would  ordinarily.
  1628.      The following primitives manipulate property lists.
  1629.  
  1630.      pprop     pprop -- Command, three inputs.
  1631.  
  1632.           The first input, which must be a word, is a name with which  a
  1633.           property  list is associated.  The second input, which must be
  1634.           a word, is the name of a property.  The third input can be any
  1635.           Logo  object.   It becomes the value of the specified property
  1636.           of the specified name.
  1637.  
  1638.      gprop     gprop -- Operation, two inputs.
  1639.  
  1640.           Both inputs must be words.  The  first  is  a  name,  and  the
  1641.           second  is  a  property  name.  The output is the value of the
  1642.           indicated property of the indicated  object.   It  is  not  an
  1643.           error if there is no such property; the output in that case is
  1644.           the empty list.
  1645.  
  1646.      remprop     remprop -- Command, two inputs.
  1647.  
  1648.                                                  gprop          The inputs  must  be  words,  as  for  gprop.   The  specified
  1649.           property is removed from the specified name.
  1650.  
  1651.      plist     plist -- Operation, one input.
  1652.  
  1653.           The input must be a word, which is a name.  The output is  the
  1654.           property  list  of  the  specified name.  Note:  the output is
  1655.           actually a copy of the property list.  The real property  list
  1656.           is  not  a  Logo list.  Any later changes to the properties of
  1657.           the specified name will not change the list which  was  output
  1658.                         plist          by an earlier plist.
  1659.  
  1660.      pps     pps -- Command, no inputs.
  1661.  
  1662.           All properties of all names are listed on your terminal.
  1663.  
  1664. LOGO PRIMITIVE PROCEDURES                                    Page 3-24
  1665.  
  1666.  
  1667.      3.9  PAUSING
  1668.  
  1669.  
  1670.      When you are debugging a  complicated  Logo  program,  it  is  very
  1671.      helpful  to  be  able to stop in the middle of a procedure, so that
  1672.      you can give interactive commands to examine its inputs  and  other
  1673.      local  variables.   This  is  different  from stopping a procedure,
  1674.      which destroys its local  environment.   There  are  three  ways  a
  1675.                                                             pause     procedure  can pause:  (1) You can include the command pause in the
  1676.      procedure definition, to make the procedure pause at  a  particular
  1677.      place  you  choose  in  advance;  (2)  you  can  decide  to pause a
  1678.      procedure while it is running  by  typing  the  system  "interrupt"
  1679.      character (this is control-C at Lincoln-Sudbury but is different on
  1680.      other systems); or  (3)  you  can  arrange  for  an  error  in  the
  1681.      processing  of  the  procedure  to  pause instead of stopping as it
  1682.      usually does.
  1683.  
  1684.      Note that when you type the system "quit" character  (control-G  at
  1685.      Lincoln-Sudbury) Logo does not pause, but returns to toplevel.  All
  1686.      information about the local state  of  your  active  procedures  is
  1687.      lost.
  1688.  
  1689.      When you are paused, Logo accepts instructions from  your  terminal
  1690.      as  it  does  at  toplevel,  but local variables can be examined or
  1691.      modified.  To let you know that you are paused, Logo  prompts  with
  1692.                        -*                   *     the  characters  "-*" instead of just "*" as usual.  It is possible
  1693.      to pause within a procedure within  a  pause;  in  this  case  your
  1694.                   --*     prompt  is  "--*"  to  indicate  two  levels of pause.  This can be
  1695.      continued to higher levels.
  1696.  
  1697.      To get out of a pause, there are three things you can do.  You  can
  1698.                         toplevel     give  the  command toplevel, which stops all pending procedures and
  1699.                                                                  stop     returns to interactive top level.  You can give the command stop or
  1700.                   output     the  command output with an input, which will terminate the current
  1701.      procedure (without or with an output respectively)  and  return  to
  1702.                                                          continue     its calling procedure.  Or you can give the command continue, which
  1703.      will resume the procedure at the point where you paused.
  1704.  
  1705.      pause     pause -- Command, no inputs.
  1706.  
  1707.           This command is meaningful only within a procedure.  It causes
  1708.           a pause.
  1709.  
  1710.      continue                                        co     continue -- Command, no inputs.  Abbreviation:  co
  1711.  
  1712.           This  command  is  meaningful  only  when  typed   during   an
  1713.           interactive  pause.   It  continues the current procedure from
  1714.           where it was paused.
  1715.  
  1716.      errpause     errpause -- Command, no inputs.
  1717.  
  1718.           This command tells Logo that any errors  which  happen  during
  1719.           procedure  execution  from now on should cause a pause, rather
  1720.           than a return to toplevel.
  1721.  
  1722. LOGO PRIMITIVE PROCEDURES                                    Page 3-25
  1723.  
  1724.  
  1725.      errquit     errquit -- Command, no inputs.
  1726.  
  1727.           This command tells Logo that any errors  which  happen  during
  1728.           procedure  execution  from  now  on should return to toplevel,
  1729.           rather than pausing.  This is the  initial  state  of  affairs
  1730.           when you start Logo.
  1731.  
  1732.      setqpause     setqpause -- Command, no inputs.
  1733.  
  1734.           This command tells Logo that from  now  on,  the  system  quit
  1735.           character  should  pause,  and  the system interrupt character
  1736.           should return to toplevel.  This is the reverse of  the  usual
  1737.           interpretation.   This  command  is  provided for people whose
  1738.           systems or keyboards make one of these  characters  easier  to
  1739.           type  than  the  other.   In particular, under Eunice there is
  1740.           only an interrupt character, not a quit character.
  1741.  
  1742.      setipause     setipause -- Command, no inputs.
  1743.  
  1744.           This command tells Logo that from now on, the system interrupt
  1745.           character  should  pause, and the system quit character should
  1746.           return to toplevel.  This is the initial state of affairs when
  1747.           you start Logo.
  1748.  
  1749.  
  1750. LOGO PRIMITIVE PROCEDURES                                    Page 3-26
  1751.  
  1752.  
  1753.      3.10  MISCELLANEOUS PRIMITIVES
  1754.  
  1755.  
  1756.      The remaining primitives are one of a kind,  or  very  obscure,  or
  1757.      both.
  1758.  
  1759.      goodbye                                        bye     goodbye -- Command, no inputs.  Abbreviation:  bye
  1760.  
  1761.           This command is used to leave Logo.  It is the only  way  out,
  1762.           unless there is a bug somewhere.
  1763.  
  1764.      thing     thing -- Operation, one input.
  1765.  
  1766.           The input must be a word, and must be the name of a  variable.
  1767.           The   output   is  the  value  of  the  variable.   These  are
  1768.           equivalent:
  1769.  
  1770.           :foo          :foo
  1771.           thing "foo          thing "foo
  1772.  
  1773.      namep     namep -- Operation (predicate), one input.
  1774.  
  1775.                                                    true          The input must be a word.  The output is true if that word  is
  1776.                                                                    false          the name of a variable which has a value assigned to it, false
  1777.           otherwise.
  1778.  
  1779.      wait     wait -- Command, one input.
  1780.  
  1781.           The input must be a positive integer.  Logo  waits  that  many
  1782.           seconds before continuing.
  1783.  
  1784.      trace     trace -- Command, no inputs.
  1785.  
  1786.           This command is used for debugging your Logo programs.   After
  1787.           you  use  this  command,  every  time a user-defined procedure
  1788.           starts or stops, a message is typed at  your  terminal  naming
  1789.           the  procedure  and  its  inputs  or  its output, if any.  The
  1790.           message is indented according to the depth in procedure calls.
  1791.  
  1792.      untrace     untrace -- Command, no inputs.
  1793.  
  1794.                                                                    trace          This command turns off the trace messages started by the trace
  1795.           command.
  1796.  
  1797.      run     run -- Command or operation, one input.
  1798.  
  1799.           The input must be a list, containing a Logo instruction  line.
  1800.           The list is run as if you typed it directly to Logo.  Example:
  1801.  
  1802.           to while :condition :cmd          to while :condition :cmd
  1803.           if not run :condition [stop]          if not run :condition [stop]
  1804.           run :cmd          run :cmd
  1805.           while :condition :cmd          while :condition :cmd
  1806.           end          end
  1807.  
  1808. LOGO PRIMITIVE PROCEDURES                                    Page 3-27
  1809.  
  1810.  
  1811.           make "number 1          make "number 1
  1812.           while [:number < 5] [print :number; make "number :number+1]          while [:number < 5] [print :number; make "number :number+1]
  1813.  
  1814.               run          The run procedure can be used as an operation, if its input is
  1815.           a  Logo  expression  which  produces  a  value,  instead  of a
  1816.           complete instruction:
  1817.  
  1818.           print run [sum 2 3]          print run [sum 2 3]
  1819.  
  1820.      repeat     repeat -- Command, two inputs.
  1821.  
  1822.           The first input must be a positive number.  The second  is  an
  1823.                                            run          instruction  list,  as  for  the run command.  The list is run
  1824.           repeatedly, the number of times specified by the first input:
  1825.  
  1826.           repeat 5 [print "hello]          repeat 5 [print "hello]
  1827.  
  1828.      repcount     repcount -- Operation, no inputs.
  1829.  
  1830.                                                                   repeat          This operation may be used only within the range of  a  repeat
  1831.           command.  It outputs the number of repetitions which have been
  1832.           done, including the current one.  That is, it  outputs  1  the
  1833.           first time through, 2 the second time, and so on.
  1834.  
  1835.      break     break -- Command, no inputs.
  1836.  
  1837.                                                                       if          This command is only meaningful within  the  range  of  an  if
  1838.                                           repeat          command  within  the range of a repeat command.  It terminates
  1839.           the repeat  immediately.   If  used  in  other  contexts,  the
  1840.           results may be strange.
  1841.  
  1842.      cbreak     cbreak -- Command, one input.
  1843.  
  1844.                                             on             off          The input must be either the word on or the word off.  If  the
  1845.                      on          input  is  on,  your  terminal is placed in cbreak mode, which
  1846.           means that what you type is made  available  to  your  program
  1847.           every  character,  rather  than every line.  This must be done
  1848.                        readchar          before  the  readchar  procedure,  below,  will  work.    This
  1849.           facility  is  good  for  writing  video  game programs or text
  1850.           editors.  While in cbreak mode, echo is turned off also.
  1851.  
  1852.      readchar                                          rc     readchar -- Operation, no inputs.  Abbreviation:  rc
  1853.  
  1854.           This operation waits for you to type  a  single  character  at
  1855.           your  terminal.   The  output  is  a word containing only that
  1856.           character.  This works only if you have turned on cbreak mode;
  1857.           see above.
  1858.  
  1859.      keyp     keyp -- Operation (predicate), no inputs.
  1860.  
  1861.                                  true          This procedure outputs true if there is a character waiting to
  1862.           be read from the terminal, if you are in cbreak mode.  If not,
  1863.                      true          it outputs true if there is an entire line waiting to be read.
  1864.  
  1865.      oflush     oflush -- Command, no inputs.
  1866.  
  1867. LOGO PRIMITIVE PROCEDURES                                    Page 3-28
  1868.  
  1869.  
  1870.           Normally, when you tell Logo to print something, the  printing
  1871.           is  not  done  right away.  Instead, Logo remembers everything
  1872.           you tell it to print, and the printing is done all at once the
  1873.           next  time  Logo  is  waiting for you to type something.  This
  1874.           arrangement makes  Logo  much  faster  than  it  would  be  if
  1875.                                                     oflush          everything were printed immediately.  The oflush command tells
  1876.           Logo to print whatever you've previously asked for right away,
  1877.           without waiting.
  1878.  
  1879.      help     help -- Command, no inputs.
  1880.  
  1881.           This command types at your terminal a brief message about Logo
  1882.           and how to use it.
  1883.  
  1884.      describe     describe -- Command, one input.
  1885.  
  1886.           The input must be the name of a Logo primitive  procedure.   A
  1887.           brief explanation of that primitive is typed at your terminal.
  1888.  
  1889.           If the input begins with the character "?" then describe  will
  1890.           list  all  the  primitive procedures which contain the rest of
  1891.           the input as a substring.  If the input is just the  character
  1892.           "?",  describe  will  list the names of ALL the LOGO primitive
  1893.           procedures.  This use of "?" is handy for trying  to  remember
  1894.           the name of a primitive procedure so that you can use describe
  1895.           again without the "?" to obtain its description.
  1896.  
  1897.           Examples:
  1898.  
  1899.              describe "print
  1900.                    describes the primitive procedure 'print'
  1901.  
  1902.              describe "?pri
  1903.                    lists the names of all primitive procedures which contain
  1904.                    the string "pri", e.g. print, fprint, fileprint, and
  1905.                    filefprint
  1906.  
  1907.              describe "?
  1908.                    lists the name of all the LOGO primitive procedures
  1909.  
  1910.      go     go -- Command, one input.
  1911.  
  1912.           This command can be used only inside a procedure.   The  input
  1913.           must  be  a  number.   The  same  number  must  appear  at the
  1914.           beginning of some line in  the  same  procedure.   (This  line
  1915.           number  is  otherwise ignored.) The next command executed will
  1916.           be the one on the indicated line  in  the  definition.   Note:
  1917.           there is always a better way to do it.  If you have previously
  1918.           programmed in BASIC, your only hope of  ever  really  learning
  1919.                                                             go          how to program computers is NEVER EVER to use the go command!
  1920.  
  1921.      debquit     debquit -- Command, no inputs.
  1922.  
  1923.           This command is meant to  be  used  only  for  debugging  Logo
  1924.           itself.   It  is  explained here only for completeness.  After
  1925.  
  1926. LOGO PRIMITIVE PROCEDURES                                    Page 3-29
  1927.  
  1928.  
  1929.           this command is used, the QUIT signal is not caught  by  Logo,
  1930.           so it will cause a core dump.
  1931.  
  1932.      memtrace     memtrace -- Command, no inputs.
  1933.  
  1934.           This command is meant to  be  used  only  for  debugging  Logo
  1935.           itself.   It  is  explained here only for completeness.  After
  1936.           this command is used,  every  allocation  or  deallocation  of
  1937.           memory,  and  every character parsed by the interpreter, types
  1938.           an incomprehensible message at your terminal.
  1939.  
  1940.      yaccdebug     yaccdebug -- Command, no inputs.
  1941.  
  1942.           This command is meant to  be  used  only  for  debugging  Logo
  1943.           itself.   It  is  explained here only for completeness.  After
  1944.           this command is used,  every  state  transition  in  the  yacc
  1945.           parser types an incomprehensible message at your terminal.
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.                                CHAPTER 4
  1961.  
  1962.                             THE LOGO LIBRARY
  1963.  
  1964.  
  1965.  
  1966.  
  1967.      The LOGO library contains Logo procedures which  are  available  to
  1968.                                           pots     all  users.   They  are  listed  by  pots, and can be thought of as
  1969.      pseudo-primitives which happen to be  written  in  Logo.   Some  of
  1970.      these  procedures  are only useful in conjunction with the teaching
  1971.      units used in Introduction to Computers, but others  are  generally
  1972.      useful.   This  manual  does  not  fully document the Logo library,
  1973.      because it changes too often.  Look through the  library  directory
  1974.                                                listp  home  pos  setpos     yourself  if  you  want.   The procedures listp, home, pos, setpos,
  1975.      towards  setx      sety     towards, setx, and sety in the library  are  provided  for  partial
  1976.      compatibility with Apple Logo.
  1977.  
  1978.      The library is identified by  the  logical  LOGO$LIBRARY.   Library
  1979.                                           show     routines  may be inspected using the show command (but they may not
  1980.      be erased or changed).  Most library procedures are well commented,
  1981.                                   pots     so  that  if you execute the pots command to list them out and then
  1982.              show     use the show command to read the descriptive comment, you should be
  1983.      able to figure out the correct use of the library procedures.
  1984.  
  1985. ""                                                        Page Index-1
  1986.  
  1987.  
  1988.                                 INDEX
  1989.  
  1990.  
  1991.  
  1992.         3-17                                  3-16arctan, 3-17                        greaterp, 3-16
  1993. Arithmetic, 3-15
  1994.                                              3-14                                    heading, 3-14
  1995.       3-9                                 3-28back, 3-9                           help, 3-28
  1996.       3-18                                      3-12both, 3-18                          hideturtle, 3-12
  1997.        3-27                                 3-10break, 3-27                         hitoot, 3-10
  1998.         3-11btouch, 3-11
  1999.           3-5                           3-18butfirst, 3-5                       if, 3-18
  2000.          3-6                                 3-18butlast, 3-6                        iffalse, 3-18
  2001.                                             3-18                                    iftrue, 3-18
  2002.         3-27cbreak, 3-27                        Infix notation, 3-15
  2003. Characters, 2-3                     Input/output
  2004.              3-11clearscreen, 3-11                     file, 3-20
  2005.        3-20close, 3-20                         Inputs, Multiple, 2-2
  2006. Comments, 2-3                       Interrupt character, 2-1
  2007.                                         3-6Conditional execution, 3-18         is, 3-6
  2008.           3-24                            3-7continue, 3-24                      item, 3-7
  2009.      3-17cos, 3-17
  2010.        3-6                                3-27count, 3-6                          keyp, 3-27
  2011.  
  2012.          3-28                                3-10debquit, 3-28                       lampoff, 3-10
  2013.           3-28                              3-10describe, 3-28                      lampon, 3-10
  2014.             3-15                          3-5difference, 3-15                    last, 3-5
  2015.                                           3-9Dynamic scoping, 2-7                left, 3-9
  2016.                                            3-16                                    lessp, 3-16
  2017.       3-2                                 3-5edit, 3-2                           list, 3-5
  2018.         3-18either, 3-18                        Lists, 2-5
  2019.         3-6emptyp, 3-6                           bracketed, 2-6
  2020.         3-16                               2-7equalp, 3-16                        local, 2-7
  2021.        3-3                                  3-10erase, 3-3                          lotoot, 3-10
  2022.           3-24                            3-5errpause, 3-24                      lput, 3-5
  2023.          3-25                               3-11errquit, 3-25                       ltouch, 3-11
  2024.  
  2025.             3-20                          2-6filefprint, 3-20                    make, 2-6
  2026.            3-20                              3-16fileftype, 3-20                     maximum, 3-16
  2027.            3-20                              3-7fileprint, 3-20                     memberp, 3-7
  2028.           3-20                                3-29fileread, 3-20                      memtrace, 3-29
  2029.           3-20                               3-16filetype, 3-20                      minimum, 3-16
  2030.           3-20fileword, 3-20                      Multi-instruction lines, 2-3
  2031.        3-5first, 3-5                          Multi-line instructions, 2-3
  2032.          3-9forward, 3-9
  2033.         3-4                                3-26fprint, 3-4                         namep, 3-26
  2034.       3-5                                3-19fput, 3-5                           not, 3-19
  2035.         3-10                                 3-16ftouch, 3-10                        numberp, 3-16
  2036.        3-4ftype, 3-4                          Numbers, 2-4
  2037.             3-11fullscreen, 3-11                      scientific notation, 2-5
  2038.                                       signed, 2-5
  2039.         3-14getpen, 3-14
  2040.     3-28                                    3-27go, 3-28                            oflush, 3-27
  2041.          3-26                                 3-20goodbye, 3-26                       openread, 3-20
  2042.        3-23                                    3-20gprop, 3-23                         openwrite, 3-20
  2043.  
  2044. ""                                                        Page Index-2
  2045.  
  2046.  
  2047.         3-22                                   3-6output, 3-22                        sentencep, 3-6
  2048. Output of a procedure, 2-2          Sentences, 2-5
  2049.                                               3-13                                    setcolor, 3-13
  2050.        3-24                                     3-13pause, 3-24                         setheading, 3-13
  2051.                                                3-25Pausing, 3-24                       setipause, 3-25
  2052.           3-12                                 3-25pencolor, 3-12                      setqpause, 3-25
  2053.          3-9                                    3-14pendown, 3-9                        setscrunch, 3-14
  2054.           3-10                             3-13penerase, 3-10                      setxy, 3-13
  2055.          3-10                             3-3penmode, 3-10                       show, 3-3
  2056.             3-10                            3-12penreverse, 3-10                    shownp, 3-12
  2057.        3-9                                      3-12penup, 3-9                          showturtle, 3-12
  2058.        3-23                              3-17plist, 3-23                         sin, 3-17
  2059.       3-3                                        3-11pots, 3-3                           splitscreen, 3-11
  2060.      3-17                                 3-17pow, 3-17                           sqrt, 3-17
  2061.        3-23pprop, 3-23                         Starting LOGO, 2-1
  2062.      3-23                                 3-22pps, 3-23                           stop, 3-22
  2063.                                          3-15Predicate, 2-2                      sum, 3-15
  2064. Predicates, 3-18                    Syntax, 2-1
  2065.        3-4print, 3-4                          System quit character
  2066. procedure                             see Interrupt character
  2067.   defined, 1-1
  2068.                                           3-18  definition, 1-1                   test, 3-18
  2069.                                                 3-12  primitive, 1-1                    textscreen, 3-12
  2070.                                            3-26Procedure definition mode, 2-1      thing, 3-26
  2071.                                         3-2Procedure exit, 3-22                to, 3-2
  2072.                                               3-22Procedures                          toplevel, 3-22
  2073.                                                3-13  definition of, 3-2                towardsxy, 3-13
  2074.          3-15                              3-26product, 3-15                       trace, 3-26
  2075.                                             3-8Prompts, 2-1                        turtle, 3-8
  2076. Property lists, 3-23                Turtle graphics, 3-8
  2077.                                           3-4                                    type, 3-4
  2078. Quit character
  2079.                                              3-26  see Interrupt character           untrace, 3-26
  2080. Quotation mark, 2-4
  2081.           3-15quotient, 3-15                      Variables, 2-6
  2082.                                       assignment, 2-6
  2083.         3-17random, 3-17                          global, 2-7
  2084.           3-27readchar, 3-27                        local, 2-7
  2085.           3-4readlist, 3-4
  2086.            3-16                           3-26remainder, 3-16                     wait, 3-26
  2087.          3-23                                  3-11remprop, 3-23                       wipeclean, 3-11
  2088.           3-27                            3-4repcount, 3-27                      word, 3-4
  2089.         3-27                               3-6repeat, 3-27                        wordp, 3-6
  2090.          3-4request, 3-4                        Words, 2-3
  2091.        3-9right, 3-9
  2092.      3-17                                 3-13rnd, 3-17                           xcor, 3-13
  2093.         3-11rtouch, 3-11
  2094.      3-26                                      3-29run, 3-26                           yaccdebug, 3-29
  2095.                                           3-14                                    ycor, 3-14
  2096.          3-14scrunch, 3-14
  2097.           3-4                              3-16sentence, 3-4                       zerop, 3-16
  2098.