






















                   THE LADYBUG'S DISCOVERY BOOK



                           I belong to                         



             _______________________________________















              As the LadyBug told it to Jim Muller

with illustrations, imagination, and invaluable contributions by

                          Charles Micha





























Copyright 1989 by James H. Muller, Richardson, Texas 75081
All rights reserved
Printed in the United States of America
First Edition (November 1989)

LadyBug Logo was developed and copyrighted by David N. Smith,
 Danbury, CT.  As described in the documentation, LadyBug
Logo is  freeware.  It and the sample procedures described in
the  documentation, can be freely distributed for non-profit
use. The procedures in this book are not part of the LadyBug
Logo.   They may be copied for personal use but cannot be
distributed  without prior written permission of the author.

The characters of the LadyBug, Logy, the Midnight Turtle,
Morf,  Mrtle, Shurlook 'olmes, and Dr. Whatson are the
property of the  Young Peoples' Logo Association, now
operating as the Logo Forum  on CompuServe Information
Service, Inc.  The names and characters  may not be
reproduced in any form without prior written  permission from
the author.  For additional information, contact  The Logo
Forum on CompuServe (76703,3005), or write care of 1208 
Hillsdale Drive, Richardson, Texas 75081.

Apple Logo and Terrapin Logo are trademarks of Logo Computer 
Systems, Inc. and Terrapin Inc. respectively.  Hercules and
IBM  are registered trademarks of Hercules Computer
Technology, Inc.,  and International Business Machines
Corporation respectively.


 
ABOUT THIS BOOK


     THE LADYBUG'S DISCOVERY BOOK is for young people of all 
ages...anyone who wants to share the fun and excitement of 
exploring Logo on and off the computer.  While it's an easy-to-
read book for learning LadyBug Logo, it's really a book about 
having fun at the computer, about exploring new ideas, about 
discovering what you and your imagination can do with LadyBug 
Logo. 

     To use this book, here's what you'll need...

>>   An IBM or compatible microcomputer.
>>   A graphics adapter. 

          Color is recommended.  If you're using a Monochrome
          display with a Hercules graphics adapter, the HGCIBM 
          program provides CGA emulation.

          LadyBug Logo does not support EGA, VGA, or MCGA 
          graphics.  It will, however, work in CGA emulation
          on IBM PS/2 and similar systems.

>>   At least one disk drive.
>>   A printer to print the book.

     THE LADYBUG'S DISCOVERY BOOK is currently available to
Logo  Forum members only.  You'll need to download the
following files:

>>   DISCVR.ZIP     A compressed text file containing this book. 
                    Use PKUNZIP.EXE to reconstruct this and other 
                    LadyBug Logo files.
>>   LADYBG.ZIP     LadyBug Logo software and Help files.
>>   LBDOC.ZIP      LadyBug Logo documentation.
>>   HGCIBM.ZIP     CGA emulation program for those using a 
                    Hercules graphics adapter.
>>   PKUNZIP.EXE    To "uncompress" these files.

These files are helpful but not essential:

>>   DISCPR.ZIP     Discovery book procedures.
>>   MUSIC.ZIP      LadyBug Logo music and sound effects files.
>>   FRACTL.ZIP     LadyBug Logo fractal geometry procedures.
>>   GRAPH.ZIP      Ladybug Logo graphics procedures.

     This book and other books will be published to provide
more  adventures for our illustrious cartoon characters:
Logy, the  turtle, and her faithful companion Morf, the
rabbit; Shurlook  'Olmes and Dr. Whatson.  For information on
illustrated copies  (with software), contact Jim Muller
(76703, 3005) via Easyplex or  through the Logo Forum.

                              - i -

ABOUT THE AUTHOR

     Jim Muller has had a lifelong interest in translating
high  technology into understandable, practical applications
--  especially for young people and the disabled.  In 1981,
he  organized a computer users group for young people.  What
started  as eight young people playing with TI Logo around a
ping-pong  table in a Texas garage became a full-time
publishing venture, the  Young Peoples' Logo Association
(YPLA).  Organized by and for  young people of all ages, this
group grew to 6000 members in 42  countries.  In 1985, the
YPLA accepted an invitation to bring  their services to
CompuServe as the Logo Forum.

     The YPLA published a monthly newspaper, software, text
and  workbooks for Logo fan(atic)s.  THE LADYBUG'S DISCOVERY
BOOK is  the latest.  Muller has been a regular contributor
to five  personal computing magazines, has written nine
books, and  numerous articles on Logo, kids and computers. 
In addition to  serving as Logo Forum administrator, he is a
high technology  writer in the Dallas/Fort Worth Metroplex,
specializing in voice  and data communications, personal and
mainframe computer  applications.


ACKNOWLEDGEMENTS

     There are far too many!  There's Larry and his friends. 
 Without their curiosity and enthusiasm, the Young Peoples'
Logo  Association never would have happened.  There's Dr.
Kathleen Martin,  the driving force behind "The Turtle's
Sourcebook," and many  other YPLA programs. There are far too
many young people from  around the world who shared their own
Great Logo Adventures with  us.  Some of those are in this
book.  There's Dave Smith and the  LadyBug.  They make this
particular book possible.  And, of  course, there's Audrey
Muller...who survived the invasion of  Turtle androids into
her home and still managed to maintain our  sense of
stability.














                             - ii -

                       Table of Contents


Welcome to The Great Logo Adventure!......................  1
To parents................................................  2
The Tortoise and the Hare.................................  5

Chapter 1.  Meet the Turtle...............................  9
   Learning Commands......................................  9
      Turtle Games Off the Computer.......................  10
   Turtle Shorthand.......................................  12
      Making a Pencil Turtle..............................  14
      Introduce yourself to the turtle....................  15
      Turtle Baseball.....................................  16
   Making Shapes..........................................  19
   Adventures With Squares................................  21
   Adventures with Triangles..............................  22
   Adventures with Rectangles.............................  24
      LadyBug's Oneliners.................................  26

Chapter 2.  Writing Procedures............................  27
      Houses, Squares, Wheels and Things..................  30
   Editing Your Procedures................................  31
   Saving Procedures......................................  33
      Learning With a Ball of String......................  35
   The Rule of 360........................................  37
      Exploring Circles...................................  40
      Star Gazing.........................................  42

Chapter 3.  Varying Variables.............................  45
  Local and Global Variables..............................  46
      Tangram Puzzles.....................................  47
  Changing Variables......................................  51
  Polygon procedure.......................................  53

Chapter 4.  Recursion.....................................  54
  Tail-end Recursion......................................  54
  Embedded Recursion......................................  55
  Toplevel................................................  58
      Amazing Mazes.......................................  59
  Fractals................................................  61
  Factorials..............................................  62

Chapter 5.  Superprocedures, Subprocedures, and such......  63
  Tessellations and Optical Illusions.....................  63
   Curves From Straight Lines.............................  67
      Logo String Art..................................... 69

Chapter 6.  Turtle Positions..............................  73
  Turtle Headings.........................................  73
  X- and Y-Coordinates....................................  74
  A Target Game...........................................  78

                             - iii -

Chapter 7.  Talk to Your Computer.........................  83
  NUMBERS, Words, Lists, and Sentences....................  84
  The Game of NIM.........................................  90
  LadyBug Mystery.........................................  91

Chapter 8.  A Few parting Words...........................  95
  Adding Some Color.......................................  95
  The Logo Robot..........................................  97
  From Two to Three Dimensions............................  98
  Folded Paper Fun........................................  98
  What's Next.............................................  100

Appendix A. The Logo Library..............................  101

Appendix B. Ladybug Logo Commands.........................  103

Appendix C. The LadyBug's Tool Box........................  107

Index.....................................................  111


































                             - iv -

Welcome to The Great Logo Adventure!


     Hi, I'm the LadyBug.  

     I speak two languages, English and Logo.  English has
been  around for a long, long time.  But Logo is only a bit
over 20  years old.  

     Logo got its start at the Massachusetts Institute of 
Technology.  In the beginning, the MIT people had to use a
very  big computer to run Logo.  A couple of years later,
they added a  floor turtle and a small keyboard that children
could use. The  children gave the turtle commands to make it
go forward, back,  left, and right, moving over a big piece
of paper drawing  pictures as it moved along.

     This was fine for awhile.  But when home computers began
to  appear, the National Science Foundation and Texas
Instruments  both asked the MIT people to make Logo work on
small computers.

     Texas Instruments introduced the first home computer
version  of Logo in April, 1981.  In January of 1982, the MIT
version of  Logo that had been developed for the Apple II
family of computers  was introduced.  Today, we call this
Terrapin Logo.  Apple Logo  from Logo Computer Systems, Inc.
was introduced later that Spring.  

     Since 1981, there have been many more versions of Logo
for  just about all personal computers and all types of
people.   Doodlebug Logo was developed for young children
from United  Cerebral Palsy.  A father in Connecticut decided
he wanted Logo  his children could use on his IBM personal
computer.  That's  me...LadyBug Logo.  That's the other
language I speak.

     If your computer speaks another kind of Logo, you can use
 this book, too.  Some things are a bit different between
other  Logos and my Logo.  You may have to make a few changes
so  keep the books that came with your Logo handy.  I'll tell
you  about some of those changes as we go along.

     Of course, I can't do all the things some other versions
of  Logo do.  But I can get you started on your very own
Great Logo  Adventure.  Maybe after you finish this book,
you'll want to get  another version of Logo.

       This is your very own discovery book.  Use it as you
sit  at the computer exploring LadyBug Logo.  You'll find
there are  lots of great things you can do with Logo right
now.  So after  you print this book, go ahead and write in
it.  You can even draw  in it.  But we'll get into that
later.  For now, why not show  your parents the next page.

                              - 1 -     

To parents:


Let's get acquainted...

     Are you among the growing number of adults who can't 
seem to understand their children?

     No, we're not talking about psychology or the generation 
gap.  I mean this in the most literal sense.  Do you find 
yourself unable to follow what your children are saying... 
things about Random Access Memory, about procedures, lists, 
artificial intelligence, recursion, loops, bugs, viruses?

     Or...maybe you've found yourself clutching your quarters
 every time you enter the local mall or pizza
parlor...wondering  if you should let your child to succomb
to the call of the latest  and greatest video game.  Well...

     Welcome to the computer revolution!

     To some of us, these times are marked by exciting change,
a  revolution in the way we think, in how we use information.
 To  others, this so-called revolution is simply revolting;
they keep  waiting for the personal computer to go the way of
the pet rock. You can join the first group and enjoy the
revolution.  Or you  can join the second group and help them
dig a very large hole in  which to hide from the onslaught of
technology.

     Assuming you want to join the revolution, then what?

     This book is one place to start.  It isn't about 
computerese, technology, RAM, ROM, DOS, ASCII, or alphabet
soup  acronyms.  It's a family book about having fun with
computers. While it's about fun, it isn't just a book of
games.  It's a book  that relishes the value of play; a book
that can make discovering  new things a lot of fun.

     THE LADYBUG'S DISCOVERY BOOK is about young people of all
 ages using the computer and LadyBug Logo as tools for
discovery.   They begin by commanding the movements of a
cybernetic turtle.   These movements of the turtle allow
children to "see" how they  are thinking.  When the sequence
of thoughts do not take the  turtle where the child intended,
the descriptive nature of Logo  allows the children to easily
retrace their thoughts or to pursue  a new tangent.  

     Multi-dimensional and multi-sensory activities done on
and  off the computer help children develop a better insight
into how  to make things happen in the real world...the world
of three  dimensions, of sight, sound, and touch.  Designing
with cut-out  geometric shapes, walking out the patterns the
turtle draws, and 

                              - 2 -  working with string
boards (all included in this book) are among  the many
activities that help children transfer the thought  processes
they learn at the computer into real-world situations.

     This is not a textbook!

     This is a book about exploring ideas.  Like the gardener,
we  plant some seeds in these pages.  You are the one to feed
these  ideas, to nurture them, and to make them grow.  So
join your  children at the computer?  And don't be surprised
if you are the  one who end up being cultivated.

     Just as important...especially if you already know
something  about Logo...don't be surprised if you find that
LadyBug Logo can  do far more than you might have imagined. 
The LadyBug Logo  documentation will tell you more about the
differences between  LadyBug Logo and other versions of the
language.  We provide a  few of the differences in these
pages. You'll find that making  those differences work for
you can be a fascinating challenge.            As you'll see
in our updated version of the classic fable,  you can
approach this book like Logy, the Logo Forum Turtle, one 
thoughtful step after the other.  Or maybe you're more like 
Morf, Logy's rabbit friend.  Morf likes to jump around a 
lot...looking, exploring, discovering all sorts of new things.
 

     You can follow the sequence of activities in the book. 
Some  may be too simple to dwell on very long.  Some may be
too  complicated.  So skip those for now.  Hopefully, you'll
make up  some of your own activities to explore.  Whatever
you do,  remember this is an idea book.            Enjoy!




                                   FD 100!

          
                                   LadyBug












                              - 3 -






















































                              - 4 -

The Tortoise and the Hare...

                          A Logo Fable




     Once upon a time, there was a tortoise who moved along
very  slowly.  The tortoise liked this slow, easy life.  It
was fun  watching the birds, the trees, and the flowers. 
There was lots  of time to learn from each new thing he saw
as he wandered about.

     Once upon that same time, there was a hare who liked to
hop  and leap about.  Now, the hare was always teasing the
tortoise  about his slow, steady pace.  But the tortoise
never replied.  He  just kept minding his own business,
enjoying each new sight and  sound.

     One day, the hare teased the tortoise one time too many.

     "Hare," he said, "I challenge you to a race.  Whoever can
 get to the other side of the forest first is the winner."

     The hare laughed so hard he fell down.  He held his sides
 as he rolled around on the ground.  Of course, the hare
agreed,  and the race began. 

     The tortoise started off at a slow, steady pace...step...
 step...step...never faster, never slower.  The hare leaped
and  hopped all over the place.  He even did cartwheels
around the  tortoise and then sped off to have some fun
before he went to the  other side of the forest.  He knew he
had plenty of time before  the tortoise would ever get
there.

     I bet you know what happened.  Maybe someone read you the
 other story about the tortoise and the hare.  The tortoise
won  the race and the hare felt very foolish.  He never
teased the  hare again.

     I bet you think that's where the story ends.  Not
quite...

     Once upon a much later time...just a few years
ago...there  was a turtle who lived near a forest.  This
turtle was a distant  cousin of the great-great-great
grandchild of that famous  tortoise.  The turtle had a friend
who was a rabbit, a distant  cousin of the great-great-great
grandchild of the not so famous  hare.

     One day, the turtle and the rabbit were both given a 
computer and Logo.  They were both very happy and could not
wait  to see what they could each do with their new
presents.


                              - 5 -            The turtle
opened the Logo book and began to read, one page  at a time.

     The rabbit opened his Logo book and just skipped over the
 first chapter.  It looked too easy.  He wanted to find the 
good stuff.  He hopped and leaped all over the place.  When 
he glanced over at the turtle, he was still reading the first
 chapter.

     "Hey, that's the easy stuff," the rabbit said. "Look at 
this!"

     The turtle liked what the rabbit did, but he was having
lots  of fun doing his own thing.  He knew he'd soon be able
to do the  things the rabbit copied from his book.

     Time passed...and the rabbit was still bouncing from one
 thing to another.  By now, the turtle had finished chapter
2.

     More time passed.  The hare took another look at what the
 turtle was doing.  He was just about to tease the turtle for
 going through the book so slow when he stopped.  

     "Hey!  How'd you do that.  That isn't in the book," the 
rabbit said.

     The turtle explained slowly, step by step, what he had
done  to make the pretty picture on the screen.  But the
rabbit was  still puzzled.

     "Yes, rabbit," explained the turtle, "this isn't in the 
book.  I made it up from what I read about in the first 
chapters."

     "But how'd you know what to do?" asked the rabbit?"

     "Gee, I thought you knew all about Logo and computers, 
rabbit," said the turtle as he turned the page to chapter
three.   "Logo is the most fun when you start with what you
know and  discover new things as you move along."

     "Logo isn't just something to do at the computer.  It's 
really about exploring new ideas...about discovering new ways
to  do things."

     "If I want to learn things, I'll go to school," said the
 rabbit.  "That's what school is for!"

     "The computer and Logo are for learning things, too," 
answered the turtle.  "They're tools just like paper and
pencils  are tools."


                              - 6 -       "Tell me
something, rabbit.  When you're in school and you  make a
mistake on your spelling test, do you blame the spelling 
book?  Do you blame the pencil and the paper?" asked the 
turtle.

     "That's silly.  The book doesn't take the test.  And the
 paper and pencil can't do anything without me.  If I make a
 mistake, that's my fault.  And if I get all the words right,
I'm  the one who gets the Gold Star!"

     "If the teacher asks you to write a story, do you copy
that  story from a book?  Or do you use the words you learned
how to  spell to write a story of your very own?"

     "I write my own stories, of course!" answered the rabbit.

     "Well, rabbit, why should the computer and Logo be any 
different.  Logo is the language you use...just like English. 
 The keyboard is your pencil and the screen is your paper. 
Now  why don't you see what you can do with them...all by
yourself."

     The poor rabbit was embarrassed enough for one day.  He
was  angry too, angry at himself for being so silly.  

     "Computers aren't that tough," thought the rabbit.  "All
I  have to do is teach it what I want it to do."

     So the rabbit sat down with his book again and began to 
read.  Soon he was doing his own thing...not the things the
book told  him to do.  Sure, he made mistakes.  But he found
that's where  the fun begins.  When he finally got his
procedures to do the  fancy things he wanted them to do, he
did a couple of cartwheels  over to the turtle.

     "Come see!  Come see!" he said very excited and he ran
back  to his computer.  

     "Yes, that's the idea," said the turtle.

     "I'm beginning to see what you mean about Logo and the 
computer.  But how did you know all this so fast?"

     "Rabbit," answered the turtle, "I have to be honest with 
you.  See that small triangle shape there on the screen?"

     "Sure, that's the turtle."

     "Yes, and that's also my cousin, Ernestine.  She's the 
LadyBug's friend who makes everything happen.  Let's just say
it  runs in the family."



                              - 7 -                       
Back in 1981, a group of young people gathered in a garage 
to have fun at the computer. From this group, the Young
Peoples'  Logo Association grew into a worldwide
organization. 

     When we first worked on this and other books on Logo, we
all  thought a lot about the turtle and the rabbit, and how
we all  first learned about what the turtle could do.  We
hope you'll be  like the turtle.  

     Take your time.  

     Move slowly, step by step.

     Watch what happens on the screen.  Remember you are the
one  making it happen.

     Start with what you know how to do.  Add bits and pieces
 together until you can do just about anything you want to
do.  If  that sounds like a lot, don't worry.  Some of our
friends will  help you.

     If you want to be like the rabbit.  That's OK, too.  Skip
 around if you want.  Explore all the many things you'll
find.  In  fact, you'll find some sections written just for
rabbits.  We  call them "Rabbit Trails" where you can take
off on some special  adventures.  In a few places, you'll be
told about activities  described in Chapter 8.  There you'll
find some special things to  do.  

     You can use the procedures on the Discovery Book disk or
you  can type the procedures into your computer...whichever
you want  to do.  

     Both the turtle and the rabbit didn't stop with the
things  in the book.  They made up there own pictures,
puzzles, games,  and music.  And when they got to the end of
the book, you should  see what they could do...all by
themselves.

     In fact, they're going to write the next book.  Wait and
 see.













                              - 8 -

CHAPTER 1.  MEET THE TURTLE


     Let's get started!

     Turn your computer on. Do you have the LadyBug Logo disk
in  disk drive A?  

     Good!  Now type LADYBUG.  Do what it says on the screen.  
When you see "Welcome to LadyBug Logo!" you're ready to begin.
                   
LEARNING COMMANDS

     Type DRAW to go to the turtle's screen and press the
ENTER key.  That's the key with the arrow on it.  It looks
something  like this... <---`  Presto!  There's Ernestine,
the LadyBug's  turtle friend, sitting at HOME, right in the
middle of the  screen.  Ernestine looks like a pointed arrow
but she's really a  turtle.

Special Note:  When you type things on the keyboard, you
               can use capital letters or small letters.  In
               this book, we use CAPITAL letters so you'll
               know what we want you to type.

     Down on the left side, you'll see a ? and a square.  That
 square is "the cursor."  It moves everytime you type
something on  the screen.  We'll talk more about the cursor
later.  For now,  let's get on with the fun!

     Ernestine moves in four directions.

     FORWARD

     BACK

     LEFT

     RIGHT

     When you tell the turtle to move, you have to tell her
how  many turtle steps to take.  Go ahead.  Try it.  Type
FORWARD.   Press the SPACE bar.  Then type a pretty big
number...like 50.   Then, for the turtle to hear you, you
have to press ENTER. 

     To turn the turtle, tell her to turn RIGHT or LEFT. 
Again,  you have to tell her how many turtle turns to take. 
(Maybe you've already heard about degrees...things like a
90-degree angle. Well, we like to call degrees "turtle
turns.")  Tell the  turtle to turn right 90 turtle turns.

     RIGHT 90
                              - 9 - 

     Get the idea?  Try a few moves on your own.

     FORWARD 50               RIGHT 90

     RIGHT _____              FORWARD 50

     BACK _____               RIGHT _____

     LEFT _____               FORWARD _____

----------------------------------------------------------
RABBIT TRAIL #1.  Turtle Games Off the Computer 

     Have you ever played SIMON SEZ or MOTHER, MAY I?  Let's
play  a turtle game that's a lot like these games.  This one
is fun to  play with your class in school or with your family
at home.

     One player is the turtle and one is the computer
operator.   The idea is to tell the turtle how to walk
through a big letter.   The others in the room have to guess
what the letter is.  The  turtle starts in the middle of the
room.  The operator then tells  the turtle how to move.

     This will give you an idea.  

     FORWARD 10     turtle steps

     RIGHT 150      turtle turns

     FORWARD 11     turtle steps

     LEFT 150       turtle turns

     FORWARD 10     turtle steps

     Now type these steps on the computer...you don't need to
 type the "turtle steps" or "turtle turns."  What letter does
this  shape look like?  

     How would you make this shape bigger on the screen?  

     If you make the turtle move five times as many turtle
steps  forward, do you have to make the turtle turn five
times as many  turns?  

SPECIAL NOTE:The words you type...FORWARD, RIGHT, BACK, and 
             LEFT...are Logo "primitives."  Primitives are the 
             action words that are the basic building blocks of
             Logo programs.  They're the things LadyBug Logo 
             can do.  As you will see in the next chapter, 
             primitives are procedures the LadyBug follows to 
             make things happen.

                             - 10 -

     Let's see what happens...

     FORWARD 10 * 5

     RIGHT 150

     FORWARD 11 * 5

     LEFT 150

     FORWARD 10 * 5

     The * sign tells the turtle to multiply 10 times 5 and
move  that many turtle steps.  

     What happened?

     The shape got bigger.  But it still looks like the letter
N  doesn't it.  So I guess that means that turtle steps and
turtle  turns are different.  Changing the number of turtle
steps changes  the size of the shape.  But it's still the
same shape.  Changing  the number of turns changes the shape
itself.  

     Go ahead...change the number of turtle turns.  Change 150
to  120.  What happens when you change it to 180?  Why not
try 310?   As you play around with numbers, you'll begin to
see how you can  make the turtle do just what you want it to
do.

     Now...what would happen if you changed the * 5 to a * 8?

     Don't worry about what you're drawing or what the
turtle's  trail looks like.  This is the time to explore...to
discover what  the turtle can do with four commands.  Go
on...give it a try!

--------------------------------------------------------------

     By now the screen is either a work of art or a mess. 
When  you want to clear the screen, there are three ways you
can do  this.

     Type CLEARSCREEN         Your drawing disappears but the
                              turtle stays where it is.

     Type DRAW                Your drawing disappears and the 
                              turtle goes HOME.

     Type NODRAW              Your drawing disappears and you 
                              find yourself at the text screen.

     Type BYE                 Leave LadyBug Logo.

     Don't forget to press the ENTER key after you type a 
command.  That's the only way the turtle will know what to do.

                             - 11 -

TURTLE SHORTHAND

     Now that you know what these commands are and what they
will  do, let's make things easy.  You can type these
commands in  shorthand like this.

     FD        is the same as      FORWARD

     BK        is the same as      BACK

     RT        is the same as      RIGHT

     LT        is the same as      LEFT

     CS        is the same as      CLEARSCREEN

     Get the idea?  Good...then let's try a few.  Here's a
list  of commands.  Some are already done for you.  Why don't
you fill  in the blanks.  Then type your own commands on the
computer. 


     FD 100         RT 120        FD 60         BK 30

     LT ____        FD ____       RT ____       BK ____


     So far we've been talking about the turtle drawing all of
 the time.  Ernestine always has her pen down to draw on the
 screen.  

     But what if you want to move the turtle without drawing? 
 What do you do then?

     You guessed it...you tell the turtle to pick up the pen.
Try it.

     PENUP or PU

     FD 50


     To tell the turtle to start drawing, tell her to put the
pen down.

     PENDOWN or PD

     FD 50


     Awfully simple?  Or simply awful?



                             - 12 -

     Did you ever type something you didn't mean to type? 
Well,  all you have to do to change it is to back up and type
over the  things you want to change.  You can use the
back-arrow key to  back up, the one with the arrow pointing
to the left.  That  doesn't do anything except move the
cursor back.  Then type over  what you want to change.

     Or you can use the DELete key.  That one erases what you
 typed as you move backwards.  Go ahead, give it a try.

     OK...we know we can erase things that we type.  But what
 about things we draw?  


     Think about this.  You have just finished a great drawing
 when you see a line that's too long.  You don't want to
start all  over again.  All you want to do is erase that one
line.

     Some versions of Logo have a PENERASE command.  In
LadyBug  Logo, you change the color of the turtle's pen to
the same color  of the screen's background color.


     Let's try it.  Type DRAW.  Then draw this shape.

     FD 50

     RT 120

     FD 50

     RT 120

     FD 60

     Rather than erase the entire drawing because the last
line  is too long, just change the color of the pen.  Type
this.

     PENCOLOR  or PC 0

     Since you want to erase that last line, you just move the
 turtle back over it.

     BACK  or BK 60

     What happened?  More important, what do you do now?

     If you said change the color of the back to what it was, 
give yourself a huge Gold Star!

     PENCOLOR  or PC 3

     FD 50
                             - 13 -

     Now what do you see?  Looks better, doesn't it.  We'll
talk  more about pen colors and background colors in Chapter
8.  If you  want to turn there now, go ahead. Then come back
so we can have  some fun with the commands you know so far.

Try this...                   Now try this...

FD 50                         RT 90

RT 45                         FD 75

FD 75                         LT 90

PC 0                          FD 100

BK 75                         PC 0

PC 1                          BK 50

____  _____                   PC 1

     Sometimes it is fun to just play around on the screen to
see  what you can do.  Other times it is fun to plan a
drawing on  paper first, and then put it on the screen.
-------------------------------------------------------------
RABBIT TRAIL #2.  Making a Pencil Turtle

     Here's an idea to help you make a turtle drawing on
paper.   Let's make a turtle for your pencil.

     Using your pencil, make a drawing of an egg on a piece of
 heavy paper or cardboard.  If you're at home, why not ask
your  Mom or your Dad for a real egg to trace.  But be
careful, you  don't want egg all over your drawing.

     Hold the egg carefully and then trace an oval around the 
egg.  This looks like a turtle shell, doesn't it.  Now put a 
small circle in the middle of your turtle shell about the size of 
your pencil.

     At the top of the shell, draw the turtle's head.  Then draw 
the turtle's right legs.  Then draw the turtle's left legs.  Now 
you're ready to cut out your turtle.

     Carefully cut around the outside of your turtle.  Then cut 
out the small circle in the middle for your pencil.  Or you can 
just push your pencil through the circle.

     Now you can draw like the turtle on your paper.

     Slide the turtle up your pencil so you can hold the pencil 
underneath the turtle.
                             - 14 -

     Make sure the turtle is looking at the top of the paper.  
Then give the turtle a command like...

     FD 50

When you want the turtle to turn, turn your pencil so the turtle 
is facing where you want to draw your next line.

     RT 90

     FD 50

Get the idea!

     When you want to plan a drawing on paper, your Pencil Turtle 
can help you think about the moves the turtle will have to make 
on the screen.  To help you even more, make a list of the 
commands you give your pencil.  Then you can type them on the 
computer.
-----------------------------------------------------------------

     You know how to tell the turtle to go FORWARD, BACK, LEFT, 
and RIGHT.  You can tell to turtle to draw with the PENUP or the 
PENDOWN.  

     Do you remember where HOME is?  

     What happens when you tell the turtle to DRAW?
     
     What about NODRAW?  CLEARSCREEN?


Time to do some exploring!

-----------------------------------------------------------------
RABBIT TRAIL #3.  Introduce yourself to the turtle.

     On your first adventure, introduce yourself to the turtle.  
Have the turtle draw the first letter of your name. 

     What about the second letter?   The rest of the letters?

     If you want to have some fun with the turtle, you might want 
to skip to the Robot game in chapter 8.  The turtle becomes a 
Robot who does what you tell her to do.



SPECIAL NOTE:  If you ever forget your LadyBug Logo commands, 
               press the F3 key.  This key loads the Help 
               screens.


                             - 15 -

RABBIT TRAIL #4.  Turtle Baseball

     Put four small stickers on the screen.  If you don't have 
stickers, use tape.  Don't press to hard.  You want the stickers 
or tape to stick.  You also want to be able to unstick them too.

     Put the first sticker at HOME.  That's the Home Plate.  Then 
put the three bases around the screen.

     Can you put the turtle on First Base in no more than three 
moves?  Good, you're safe.  Now go to Second Base in three moves 
or less.  Then go to Third.  And now go Home.

     Get some friends together and see who can run the bases in 
the fewest number of moves. To add some more fun to your game, 
move the stickers to different spots on the screen. 

     If you don't want to use stickers, try the Connect-the-Dots 
game on the Discovery disk (CONNECT.BUG).  This does the same 
thing with a few surprises along the way.
-----------------------------------------------------------------

How big is the computer screen?

     Take the turtle HOME.  Do you remember how to do that?  You 
can type HOME.  What's another way?

     How many steps will the turtle take before she disappears 
off the top of the screen?  Where does Ernestine go?

     As soon as the turtle goes off the top of the screen, she 
reappears at the bottom.  This is called "wrapping."  When you 
want the turtle to wrap around the screen, the command is WRAP.

     What if you don't want Ernestine to wrap around the screen.  
What do you think the command will be?  In other versions of 
Logo, the command is sometimes called NOWRAP.  But in LadyBug 
Logo, the command is WINDOW.  You tell the turtle to go out the 
window at the edge of the screen and keep on going!  Try it!

     WINDOW

     FD _____

     HOME

     WRAP

     FD _____


     Enough of this stuff for now...let's take another look at 
the screen.
                             - 16 -

The turtle's screen...

-----------------------------------------------------------------
|                                                               |
|  <----------------  500 turtle steps wide  ---------------->  |
|                     300 turtle steps tall                     |
|                                                               |
|                                                               |
|                                                               |
|                                                               |
|                 HOME is in  /\  the center.                   |
|                                                               |
|                                                               |
|                                                               |
|                                                               |
|                                                               |
| ?   You have two lines at the bottom for typing commands.     |
|                                                               |
-----------------------------------------------------------------

     Different computers have different screen widths.  Your 
screen may not be quite 500 steps wide and 300 steps tall.  So why not take a few minutes to measure your screen?

     DRAW

     FD 150

     RT 90

     FD 250

     HOME

     What do you see on the screen?  If you see a complete 
triangle, then you know that your screen is 500 steps wide by 300 
steps tall, right?  If not, do some experimenting to see how wide 
and how tall your screen is.


     My screen is _____________ turtle steps wide.


     My screen is _____________ turtle steps tall.



Remember these numbers.  You'll need them a little later on.





                             - 17 -

     Now...why not make up some rabbit trail adventures of your 
own?

     To give you an idea, one of our friends added some fun to 
Turtle Baseball.  If a player did not get to a base in three 
moves, they had to stop and draw a small square...

     REPEAT 4 [FD 5 RT 90]

     When this was done, the player had to pick up the pen and go 
home, like this.

     PENUP HOME PENDOWN

     Then a player from the other team then had to put the turtle 
inside the small square in three moves. If that player could not 
put the turtle inside the small square, the first player was 
safe.  You can learn more about this by playing the game, 
BASEBALL.BUG on the Discovery disk.

     There's all sorts of things you can dream up, I'll bet.  Go 
on...see what you can do!

My Rabbit Trail Adventure
-------------------------




























                             - 18 -

MAKING SHAPES

     Let's play turtle.  You can use your Pencil Turtle, you can 
use yourself, or you can use some of your friends.

     Start with an easy shape...like a square.  Do you know what 
makes a square different from, say, a triangle?  Or a rectangle?  
Well, for one thing, all the sides of a square are the same size.

     Tell the turtle to go HOME.  Pretend that's in the middle of 
the room or the middle of your paper.  Now -- what commands must 
you give the turtle to draw a square?  


     FORWARD _______ TURTLE STEPS     Are you going to make a
                                      BIG square or a little
                                      square?  
     
     TURN RIGHT ______ TURTLE TURNS   You can turn left if you 
                                      want.  But how many turns
                                      do you have to make?  30?
                                      60?  90?  120?

     FORWARD ______ TURTLE STEPS      Make this the same number 
                                      of steps.

     TURN RIGHT ______ TURTLE TURNS   How many turns should you 
                                      make here?  Should this be 
                                      the same number of turns as 
                                      you made above?

     FORWARD ______ TURTLE STEPS      Make this the same number 
                                      of steps.

     TURN RIGHT ______ TURTLE TURNS   How many turtle turns this 
                                      time?  

     FORWARD ______TURTLE STEPS

     TURN RIGHT ______ TURTLE TURNS


     What did you discover about a square.  Sure, the four sides 
have to be the same.  But what about the corners?  How many 
turtle turns must you make to draw a square?  Why?
     
     Let's try this on the computer.  When you have LadyBug 
Logo running, type DRAW.  Then tell the turtle to draw a square.

     FD   ______     RT   ______     FD   ______      RT   ______

     FD   ______     RT   ______     FD   ______      RT   ______       
                            - 19 -

     Wow, that's a lot of typing.  There has to be an easier way!

     Take a look at that last page.  How many of you went FORWARD 
50?  How many went FORWARD 100?  How many went FD some other 
number of steps?

     Look at all the commands together?  Do you see what you did?

     You repeated the commands FD 50...or how many steps you told 
the turtle to move...and RT 90 four times.  So let's try a new 
command.

     REPEAT 4 [FD 50 RT 90]

     This tells the turtle to REPEAT the list of tasks inside the 
brackets four times. 

SPECIAL NOTE:  When you're using LadyBug Logo, you have to 
               remember to put a space between the number of 
               times you're going to repeat and the bracket.  By 
               the way, remember that brackets have square 
               corners and parenthesis have no corners...(like 
               these).  In Logo, you don't want to get these 
               mixed up.

     OK, let's try some other squares.  You fill in the steps.  
The number of turns has to be 90, right?  

     REPEAT 4 [FD ______ RT 90]

Make a great big square!

     REPEAT 4 [FD ______ RT 90]    

Make a little bitty square!

     REPEAT 4 [FD ______ RT 90]     

TERRIFIC!

     Now for a tough one.  Put a square inside a square?  That 
means you have to draw a big square, pick the pen up, move inside 
the big square, and draw a little square.

     I left out one of the steps.  Do you know what it is?  

     Draw a big square.

     Pick the pen up.

     Move inside the big square.


                             - 20 -

     That's it...you can't draw another square until you put the 
pen back down, right?  

     OK. no more tricks.  Now draw a little square.

ADVENTURES WITH SQUARES


There's lots of things you can do with squares.

     Draw a little square first and then draw a big square around 
the outside.

     Draw a big square and then put a little square in the 
corner.

     Draw a square and then stack some other squares on top of 
it.
































     Don't forget to write down your ideas.  You may just want 
some of these ideas later on.

                             - 21 -

ADVENTURES WITH TRIANGLES

     Now...ready to tackle a triangle?  What makes a triangle 
different than a square?

     That's right, a triangle has three sides and three corners.  
A square has four of each.  A square has four equal sides and 
four equal corners or angles...angles are the same as turtle 
turns.  But what about a triangle?  Do all the sides and corners 
have to be the same or can they be different?

     If you said the sides and the corners can be different, give 
yourself a big Gold Star!  But there's a funny thing about 
triangles.  If all the sides ARE the same, can the angles be 
different? 

     Give yourself a Gold Star if you said No!  But how do you 
know?  If all the sides are the same, why do the angles have to 
be the same?  Let's explore some triangles and see if we can 
figure this out.

     Get LadyBug Logo running and then type DRAW.  Let's start 
where we left off with the squares. 

     FORWARD 50

     RIGHT 90

     FORWARD 50

     OK!  Now you have two sides and one angle on the screen.  A 
triangle has three sides and three angles.  So, let's make a 
triangle.  The easy way is to just type HOME.

     There's a triangle, three sides and three angles.  We know 
for a fact that two of the sides are equal.  You typed FORWARD 50 
two times, right?

     Look at the angle down near HOME.  Compare that with the one 
in the upper right.  Do they look to be the same?  Are they the 
same as the corner you made when you went RIGHT 90?  With the 
turtle at HOME, type

     RIGHT 90 FORWARD 50 

     Hey!  That looks like three sides of a square.  What 
commands do you need to finish the square?  RIGHT 90 sends you in 
the wrong direction.  So try...

     LEFT 90 FORWARD 50

     Now you should be at the upper right corner of a square that 
is also two triangles, correct?
                             - 22 -

     To see your drawing more clearly, let's try a new command.

     Type HIDETURTLE and press Enter.  Ernestine disappears!

     You can abbreviate HIDETURTLE by typing HT.  In LadyBug 
Logo, you can also type HB for HIDEBUG.

     Now type HOME.  To see the turtle again, what do you think 
command will be?  Sure, SHOWTURTLE or SHOWBUG.

     OK, the turtle is back home.  And there's two triangles and 
a square on the screen.  Wow!

     Look at the angles there at HOME.  Compare them with the 
angles in the upper right corner of the square.  Do all the 
angles look the same?

     You're right.  They are the same.  Let's check this out.  
Type DRAW to clear the screen and take the turtle HOME.  Then 
type

     FD 50 RT 90 FD 50 HOME

     Do you think we can make a rule from all this?  I think so.  
Seems to me that when you have two equal sides to a triangle, 
you're going to have two equal corners or angles.  Just to make 
sure, let's try another triangle.

     Clear the screen by typing DRAW.  Then try this...

     FD 100 RT _______ FD 100 HOME

     Do you see two equal sides and two equal angles there on the 
screen?  Try it again a few times...just to be sure.


     FD 100 RT _______ FD 100 HOME

     FD 100 RT _______ FD 100 HOME

     FD 100 RT _______ FD 100 HOME


     Now try this one...

     FD 100 RT 120 FD 100 HOME

     Do you see anything different about this triangle?  Let's 
check this out.  Type 

     RT 60 FD 100 


                             - 23 -

     What do you see?  Seems all three sides are equal now, 
aren't they?  And if the side are equal, what about the angles?

     Well, that's easy to check, too!  All we have to do is use 
the REPEAT command to draw three sides and three corners.

     REPEAT 3 [FORWARD 100 RIGHT 120]

     Wow!  It works!  And just to be completely certain, let's go 
back to the triangle with two equal sides.

     FD 100 RT 90 FD 100 HOME

     Now let's check that last line.  Turn RIGHT 45 and go 
FORWARD 100.  Did this take you back to the other corner?  No, 
not quite.  So, looks like we proved something about triangles.

     >  If you have three equal sides, you'll have three equal      
        angles.

     >  If you have two equal sides, you'll have two equal angles.

     >  If you have no equal sides, none of the angles will be      
        equal.


ADVENTURES WITH RECTANGLES

     Speaking of rules, what about squares and rectangles?  We 
know a square has four equal sides.  Because the four sides are 
equal, the four angles are equal.

     What makes a square different from a rectangle?  Or is it 
different?  Let's draw a rectangle.  You fill in the blanks.

     Rectangle #1             Rectangle #2

     FD ______                FD ______

     RT ______                RT ______

     FD ______                FD ______

     RT ______                RT ______

     FD ______                FD ______

     RT ______                RT ______

     FD ______                FD ______

     RT ______                RT ______

                             - 24 -

     What rules did you discover when trying to draw a rectangle?

     Can you draw a rectangle where all four sides are different 
lengths?  Not very easily, right?  In fact, that's not a shape at 
all, correct?

     Can you draw a rectangle with only two equal sides?  Nope, 
that didn't work either, did it.

     Can you draw a rectangle that has two sets of equal sides; 
where two sides are 50 steps long and two other sides are 100 
steps long?  

     Yes...that's something we can do.  

     What does this tell you about the angles?  They all have to 
be 90 turns, or 90 degrees...just like the square.  Go ahead.  
Try some rectangles.


     REPEAT 2 [FD ______ RT 90 FD ______ RT 90]

     REPEAT 2 [FD ______ RT 90 FD ______ RT 90]

     REPEAT 2 [FD ______ RT 90 FD ______ RT 90]

     REPEAT 2 [FD ______ RT 90 FD ______ RT 90]

     REPEAT 2 [FD ______ RT 90 FD ______ RT 90]

     What happens when you make the number of turtle steps the 
same for both blanks?  You got it!  That's a square!

     So, I guess we can make some rules about rectangles and 
squares.

     >  A rectangle has to have four equal angles and four sides.

     >  A square is a rectangle with four equal sides and four 
        equal angles.

     >  A rectangle will two sets of equal sides.









     Awfully simple?  Or simply awful?

                             - 25 -

RABBIT TRAIL #5.  LadyBug's Oneliners


     Think about all the things you know how to do now.  You can 
move Ernestine around the screen.  You can draw squares, 
rectangles, and triangles using the REPEAT command.  Why not put 
them all together in a Big, Fantastic, Gorgeous "oneliner."

     What's a "oneliner?"  Well, why not start with this one.

     REPEAT 12 [REPEAT 4 [FD 100 RT 90] RT 30]

     Looks something like a flower, doesn't it?

     REPEAT 6 [FD 100 [REPEAT 6 [FD 10 BK 10 RT 60] BK 100 RT 60]

     What's that look like?

     REPEAT 6 [FD 100 REPEAT 60 [FD 20 BK 20 RT 6] RT 60]

     What about this one?


     All of these are nice shapes.  But why not some crazy 
shapes...just to discover what you the turtle can do.

     REPEAT 12 [FD _____ RT _____ BK _____ LT _____]

     
     Now...why not see who can make up the prettiest "oneliner."     























                             - 26 -

CHAPTER 2.  WRITING PROCEDURES



     Bet you're getting tired of typing all those commands over 
and over and over again.  Well, there is a way to teach the 
turtle how to draw squares, rectangles, triangles, flowers, 
snowflakes and other things...and she won't forget.
          
     As you will see as you go through the rest of this book, you 
can teach the turtle to do all sorts of things...lot's more than 
just drawing shapes.  But since that's what we've been doing, 
let's write procedures for drawing shapes.  Then we'll put these 
procedures together to create some bigger and better drawings. 

     First of all, what is a procedure?  What procedure do you 
follow when you wake up in the morning?  You get out of bed, 
brush your teeth, get cleaned up, put on your clothes, eat your 
breakfast, go to school.

     Procedures are things you can do.  Logo procedures are 
things Logo can do.  They're action words.  The simplest 
procedures are the Logo primitives you've already learned...FD, 
RT, LT, BK, PD, and so on. Now you're going to learn how to write
your own procedures.  

     When you write a procedure to draw a picture, you teach 
Ernestine to do something.  This is why you always start a 
procedure with TO.  Why not teach the turtle how to make the shapes you 
made?   

     The simplest shape you made before was the corner.  So let's 
teach the turtle

     TO CORNER

     When you type this in LadyBug Logo and then press ENTER, 
you'll see a message on the screen...

     Enter lines; end with 'end'
     ?_

The cursor will be sitting right next to the question mark, 
waiting for you to type in the commands to make a square.  
Type...

     FD ______ RT 90

Fill in any number you want.  You can change it later if you 
want.  Then type END.  The turtle will then send you a message 
that says...

     corner defined
                             - 27 -

     You've now defined a procedure for the turtle.  It's like a 
new primitive, so give it a try.  Type...

     CORNER          

     Hey!  How 'bout that!  There you are at the turtle's screen 
with a corner drawn right in the middle.  

     Now...can you use your new procedure to make a square?

     Sure you can.  Go ahead and type CORNER again.  What 
happened?  What would happened if you typed it again?  And 
again?

     Well...why not just type this:

     REPEAT 4 [CORNER]

     Now we're getting some where.  Let's write a procedure for a 
square.

     TO SQUARE
     REPEAT 4 [CORNER]
     END

     Run your new procedure.  Now we're rolling.

     Remember the commands we wrote for a triangle with equal 
sides?

     REPEAT 3 [FD 100 RT 120]     

     Now we can make that a procedure too!  Since TRIANGLE is a 
long word, why not make a shorter name for the procedure.  Call 
it TRI, for example.  If you want, you can call it...
SUPERCALIFRAGILISTICEXPIALIDOCIOUS...or maybe just T.

     TO TRI
     REPEAT 3 [FD 100 RT 120]
     END

     Notice that the number of turtle steps for a side was 
changed to make the side of our triangle the same size as the 
Square.

     What do you think would happen if we put the triangle on top 
of the square?  Try it.  Don't worry about getting it right the 
first time.  Play around with your new procedures and see what 
you can come up with.  I came up with a shape that looks like a 
house.  So I wrote a procedure...



                             - 28 -

     TO HOUSE
     SQUARE
     FD 100 RT 30
     TRI
     END

     Now its time for you to do some things on your own...

     Add a door to your house.

     Add a window to your house.

     Add a chimney.

     How about a native hut?

     TO HUT
     REPEAT 4 [FD 60 RT 90]
     FD 60 RT 30 FD 60 RT 120
     REPEAT 20 [BK 6 FD 66 BK 60 RT 3]
     END

     Maybe this procedure will give you some ideas of your own.  
Write one procedure to draw several houses. 





























                             - 29 -

RABBIT TRAIL #6.  Houses, Squares, Wheels, and Things

      What else can you do with these shapes?  One young lady 
made a wheel out of the house procedure.  How do you suppose she 
did that? 

     Well, let's take a look at the house procedure.

     TO HOUSE
     SQUARE
     FD 100 RT 30
     TRI
     END

     Before you run the HOUSE procedure, hide the turtle.  Do you 
remember how to do that?  If not, turn back to page 22 and check.

     Now that the turtle is hidden, type HOUSE.  Now type house 
again.  What happened?  Try it again.  What happened this time?  
Anything different?

     Now try this one...

     REPEAT ____ [HOUSE]

     What number will you put in this command to make our 
friend's wheel?     

     Once you get the number right, you can write a new 
procedure.

     TO WHEEL
     HT
     REPEAT ____ [HOUSE]
     END

     Now that you've got a wheel, what do wheels do?  How about 
making a car procedure?  Maybe a train?  

     What things can you dream up that use the square and 
triangle shape?  How about a rocket ship?  Write down all the 
things you can think of that use squares and triangles.

 
                         








                             - 30 -

EDITING YOUR PROCEDURES

     Sometimes your procedures don't do exactly what you want 
them to do.  You have to change them.  In Logo, we call this 
"editing."  Guess where we go to do that?
     
     Give yourself a Gold Star and double-dip ice cream cone if 
you said go to the "editor."  Type...

     ED "HOUSE     or 
     EDIT "HOUSE   

Presto!  Here's a new screen.  
_________________________________________________________________
to "house                                                          REPEAT 4 [CORNER]                                                  FD 100                                                             RT 30                                                              TRI                                                                end                                                                             
                                                                                
                                                                               
             
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                


                                                                                
                                                                                
                                                                                
                                                                                
========== File: HOUSE ===== Line: 1 Col: 1   Rep =============== 
F5=Clear  F6=ClearEOL  F7=QUIT  F9=DONE  Sh-4=UnDO  Sh-F8=DelLine  _________________________________________________________________

     This is the LadyBug's editor.  Your procedure is listed at 
the top of the screen.  At the bottom, there's some things that 
help you keep track of what you're doing.

     Next to the word, File:, is the name of your procedure.  Use 
the arrow keys to move around the screen.  Watch the numbers next 
to Line: and Col: as you move.  Line: tells you which row you 
are on.  Rows count down from the top.  Col: counts the columns 
from left to right.


                             - 31 -

     You can even move off the screen to the right, or to the 
bottom.

     Why not try it...just to see how it works.  Use the down 
arrow key to move down below the word, "end."  Watch the numbers 
change in the Line:   

     Now pick a letter and hold the key down.  When you get to 
the edge of the screen what happens?  Just keeps on going, doesn't it.  The Col: number just keeps getting bigger and bigger.  

     How big does it get?  What happens?

     When it gets to 254, it stops.  That's because you can't 
type a line longer than 254 columns.  If you press the down arrow 
key, you'll find the Line: number doesn't go higher than 500.  

     Look at the bottom of the screen.  F5 and the other messages 
there refer to the function keys on the far left of your 
keyboard. 

     F5=Clear       Clear the screen
     F6=ClearEOL    Clear to the End Of the Line
     F7=QUIT        Leave the Editor without saving or changing 
                    anything. 
     F9=DONE        Leave the Editor with all of the changes 
                    saved.
     Sh-4=UnDO      Sh-4 means press SHIFT and the number 4 key 
                    together.  This erases any changes you just 
                    made but leaves you in the Editor.
     Sh-F8=DelLine  Sh-8 means pressing the SHIFT and 8 keys. 
                    together.  This deletes the line you're on.

     One more thing; you'll find that your DEL key, the arrow 
keys, and your other direction keys on the keyboard work just 
fine in the Editor.

     Why not do some exploring!














                             - 32 -

OK...do you remember what procedures you have written?

     HOUSE
     SQUARE
     TRI
     CORNER

     Maybe you wrote some others for a chimney, a door, or a 
window.  Now let's save them.

SAVING PROCEDURES

     Saving your work is easy.  Just type...

     SAVE "HOUSE

     Now all the procedures you've written are saved under that 
name.  Let's see how this works.  Type...

     LOAD "HOUSE    You can also type READ "HOUSE.  READ and LOAD
                    do the same things.

     The disk drive starts going and soon you see...

     poly defined
     house defined
     square defined
     tri defined
     corner defined

and all the other procedures you had in the workspace when you 
saved HOUSE.

     Where'd that POLY procedure come from.  The LadyBug includes 
that one each time you load any procedure.  If you don't want it 
there, just erase it.

     ERASE "POLY

     You can erase any or all of the procedures in your 
workspace.  Go ahead...try it.  Type...

     ERASE ALL

     Now what happens when you type HOUSE.  The LadyBug comes 
back and says...

     I don't know how to HOUSE.

     If you want to see your house, what do you have to do?  You 
load it back into the workspace, right?  Well, don't just sit 
there, go ahead and do it!

                             - 33 -

     LOAD "HOUSE

     And there you are.  The list of procedures loaded is right 
there on the screen again.

     Are there any other procedures saved on your disk?  Type...

     CATALOG

     There you are...a list of other procedures you can use.  All 
the LadyBug procedures have BUG as an extension to the procedure 
name.  To run any of those procedures, just type...

     LOAD <procedure name>
or     
     READ <procedure name>   

     Why not take some time to explore these procedures.  If you 
want, write down those you really like.


     I loaded ____________________.  It was ____________________.


     I loaded ____________________.  It was ____________________.


     I loaded ____________________.  It was ____________________.


     I loaded ____________________.  It was ____________________.


     I loaded ____________________.  It was ____________________.


     I loaded ____________________.  It was ____________________.
















                             - 34 -

RABBIT TRAIL #7.  Learning with a Ball of String


     Now it's time for a little fun off the computer.

     You're going to need a piece of wood from which you can cut 
a square that is about 12 inches on each side.  Use a piece of 
shelf board or a piece of plywood.  You're also going to need 
thirteen nails, a hammer, a pencil, and about 12 feet of yarn.  
String will do.

     >  Hammer a nail into the center of the board...just part 
        way so that you have an inch or more sticking up from the 
        board.  

     >  Tie the string to the nail in the center.  

     >  Now you're going to make a circle around the center nail.
        
        -  Stretch the string out to the edge of the board.

        -  Put your pencil out near the edge of the board.  (Hold
           it up straight.)  Then wrap the string around the 
            pencil.

     >  Hold the pencil up straight and stretch the string out  
        from the nail.  Then draw a circle around the center 
        nail.

     Now we're ready to hammer the other twelve other nails into 
the board.  But first, do you have a printer that can print 
pictures?  If so, the turtle can make you a pattern for your 
string board.

SPECIAL NOTE:  To print pictures, you must have the DOS GRAPHICS 
               program loaded.  If you're going to do a lot of 
               printing, you can make a BAT file to load LadyBug 
               and Graphics at the same time.

               First copy the GRAPHICS program from your DOS 
               diskette to your LadyBug Logo diskette.  Type...

               COPY CON: LADY.BAT
               GRAPHICS
               LADYBG
               ^Z         (Press Ctrl and Z at the same time.)

               Now to load LadyBug Logo and the Graphics program, 
               you just type LADY.




                             - 35 -

     Do you remember the triangle procedure, the one for a 
triangle with equal sides?

     TO TRI
     REPEAT 3 [FORWARD 120 RIGHT 120]
     END

     Now lets use that procedure to make a pattern.

     REPEAT 12 [TRI RIGHT 30]

     Wow!  There's a pattern with twelve points, just like the     numbers on a clock.  Print the screen using PrtSc; press the 
Shift key and the PrtSc key at the same time.

     Now carefully push the pattern over the nail in the center 
of the board.  Hold or tape the pattern in place.  Then draw a 
line along each of the pattern lines to the circle you drew 
before.  Where each line crosses the circle, hammer in a nail.

     Looks like a clock doesn't it.

     Well, now you and the string can play turtle graphics.

     Take the string from the center nail...that's HOME on the 
screen...and stretch it up to the nail at 12 o'clock.

     Go around the 12:00 nail and take the string around the 3:00 
nail.  Then take the string home.

     What shape did the string make?

     Now do the same thing, only go around the 1:00 nail and the 
4:00 nail.  Then go around the 2:00 nail and the 5:00 nail, the 
3:00 nail and the 6:00 nail, the 4:00 nail and the 7:00 nail.  
Continue on all the way around.

     What pattern has the string made?  Looks just like the one 
you printed, doesn't it.

     Your hand acted like the turtle, didn't it.  But instead of 
drawing lines on the screen, you made a line of string.

     Look at the procedure that made the pattern...

     REPEAT 12 [TRI RIGHT 30]

     Your first TRI went from HOME, around the 12:00 nail, around 
the 3:00 nail, and then HOME.  Then did you turn RIGHT 30 turtle 
turns?  Guess so, right?



                             - 36 -

THE RULE OF 360


     Ok...if you turned RIGHT 30 twelve times, how many turtle 
turns are there in the circle?

     That's easy.  That's 12 times 30 turns or 360.

     Take a look at your shape procedures.

     TRI       REPEAT 3 [FD 100 RIGHT 120]
     SQUARE    REPEAT 4 [FD 100 RIGHT 90]

     What about a five-sided shape?  That's a pentagon, just like 
that big building near Washington, D.C.

     PENTAGON  REPEAT 5 [FD 100 RIGHT ____]

     Look at TRI.  3 repeats times 120 turns = ______

     What about SQUARE?  4 repeats times 90 turns = ______

     What goes in the blanks?  Bet it's 360 turns.

     So, if you want to right a procedure for a PENTAGON, how 
about this.

     REPEAT 5 [FD 100 RIGHT 360/5]

     If you can do that for a 5-sided shape, bet you can do that 
for any number of sides.  Try it...


     REPEAT 6 [FD 100 RIGHT 360/6]

     REPEAT 7 [FD 100 RIGHT 360/7]

     REPEAT 8 [FD 100 RIGHT 360/8]

     REPEAT 9 [FD 100 RIGHT 360/9]

     REPEAT 15 [FD 100 RIGHT 360/15]

Now make up some shape of your own.

     REPEAT ___ [FD 100 RIGHT 360/____]         

     REPEAT ___ [FD 100 RIGHT 360/____]         

     REPEAT ___ [FD 100 RIGHT 360/____]         

     REPEAT ___ [FD 100 RIGHT 360/____]         

                             - 37 -

     What happens when the number of repeats gets pretty big?  
What does the shape look like?

     One of the first things you notice is that the shapes begin 
to go off the screen.  When this happens, make the number of 
FORWARD steps smaller.

     REPEAT 90 [FORWARD 5 RIGHT 360/90]

     REPEAT 180 [FORWARD 2 RIGHT 360/180]

     The higher the number of repeats, the more the shape begins 
to look like a circle.

     If that's true, then what would the procedure for a circle 
be?

     REPEAT 360 [FORWARD 2 RIGHT 360/360]

     That's the same as...

     REPEAT 360 [FORWARD 2 RIGHT 1]

     Of course, circles don't have to go to the right.  Why not 
try a circle to the left?

     REPEAT 360 [FD 2 LEFT 1]

     REPEAT 360 [FD 2 RIGHT 1]

     Gee, sort of looks like cross-eyes, doesn't it?


A Challenge:

     How would you put two smaller circles inside these big ones?

     Solving this challenge is like solving any problem.  Start 
with what you know.
     
     The turtle just drew two large circles by going FORWARD 2 
steps, RIGHT...and LEFT...1 turtle turn 360 times.

     Now...what do you need to know?  You need to know how to 
change the procedure so the circles will be smaller.

     There are three things you can change.  You can change the 
number of REPEATs.  You can change the number of turtle steps and 
the number of turtle turns.  But, we have already learned that to 
draw a circle, you tell the turtle to...

     REPEAT 360 [FORWARD ____  RIGHT or LEFT 1]

                             - 38 -

     So...to draw a smaller circle seems like we have to make the 
number of steps smaller.  So try this...

     REPEAT 360 [FORWARD 1 RIGHT 1]

     Looks OK, doesn't it.  Draw a circle to the left.  Now that 
really looks like cross-eyes.  Why not try some other drawings 
using circles and the other shapes you've been using.  Draw some 
shapes here.  And then draw them on the screen.












































                             - 39 -

RABBIT TRAIL #8.  Exploring Circles
               

     Write a procedure to draw a circle.  That's not too tough, 
is it?

     REPEAT 360 [FD 1 RT 1]

     OK...that looks like a circle.  But just what is a 
circle...really?  

     If you ask a math teacher, you'll find that a circle is a 
closed line where every point on the line is the same distance 
from a fixed point.  Now...can you write a procedure to draw a 
circle like this?

     Let's make HOME our fixed point...the center of our circle.  
Next we have to draw a line so that every point on that line is 
the same distance from HOME.  How can you do that?

     You'll have to pick the pen up, go out to where you want 
your circle to be, draw a point, come back, turn a little bit, go 
out the same distance, draw another point...and so on.  Before we 
get started with the line, let's write a procedure to draw a 
point.  

     TO POINT
     PD RT 90 FD 1 BK 1 PU
     END

See what that does?  Now let's put this procedure to good use.

     TO CIRCLE 
     HOME CS
     REPEAT 360 [FD 50 POINT BK 50 RT 1]
     END

The procedure starts from HOME with a clear screen. Now, rather 
than go FD 1 and RT 1, the turtle goes FD 50, draws a point, goes 
back HOME, and turns right 1 turtle turn. You draw a line where 
every point on that line is the same distance...50...from the 
center.
  
     Remember this procedure. We're going to have more fun with 
it later on.








                             - 40 -

Now..remember what you learned about that number...360?

     Seems that when you add up the angles you need to draw any 
closed shape that is made from straight lines, you come up with 
360.  And if that's true, there should be a procedure that will 
draw any shape you want.  

     What do you think those shapes are called?  Squares, 
triangles, rectangles, hexagons, octagons?  All of these shapes 
are "polygons."

     Wonder what command would let you draw any type of polygon?

     Take a look at these commands again.  How would you write 
one procedure that would draw all of them?  We'll take a look at 
this problem in the next chapter.


     REPEAT 5 [FD 100 RIGHT 360/5]

     REPEAT 6 [FD 100 RIGHT 360/6]

     REPEAT 7 [FD 100 RIGHT 360/7]

     REPEAT 8 [FD 100 RIGHT 360/8]

     REPEAT 9 [FD 100 RIGHT 360/9]

     REPEAT 15 [FD 100 RIGHT 360/15]

     REPEAT ___ [FD 100 RIGHT 360/____]         

     REPEAT ___ [FD 100 RIGHT 360/____]         

     REPEAT ___ [FD 100 RIGHT 360/____]         

     REPEAT ___ [FD 100 RIGHT 360/____]              
















                             - 41 -

RABBIT TRAIL # 9. Star Gazing


     Draw a big pentagon on the screen.  Remember how to do that?

     REPEAT 5 [FD 100 RT 360 / 5]

     Now print the screen.  Take a pencil and a ruler and draw a 
diagonal line to each corner.  In this way, every corner is 
connected to every other corner by a line.

     What do you see inside the pentagon?  I see a big star, how 
about you?

     Now draw a big hexagon on the screen.

     REPEAT 6 [FD 100 RT 360 / 6]

     Draw diagonal lines to connect all the corners and what do 
you see?  There's a Star of David, right?  That's a six-pointed 
star.  Try this with an octagon.  Now that's a lot of lines to 
draw.

     How would you draw a star on the screen?  Do these drawings 
help you figure it out?

     Take a look at the pentagon.  To draw the shape, the turtle 
goes FD 100 RT 360 / 5...that's RT 72.  The angle outside the 
shape is 72.  What's the angle inside the shape?  

     Let's find out.  Clear the screen and draw another big 
pentagon.  Make sure you can see the turtle.  Type...

     FD 100 

     The turtle has now moved up the first side of the pentagon, 
right?  What's the command to make the turtle turn around and 
head back to HOME?  That's RT 180, isn't it...half a circle?
Go ahead...try it.

     RT 180 FD 100 

     Now where's the turtle?  Type HOME and see what happens.  
All the turtle does is turn around.  She's back home.  So let's 
try something else.

     FD 100 RT 72

     The turtle is heading up the second side of the pentagon.
Now the big question?  How far do you have to turn to send the 
turtle down the first side to HOME?


                             - 42 -
     
     That's not that hard, really.  We turned 180 the first time, 
right?  What's 180 - 72?  I get 108.  What do you get?  Try it...

     RT 108 FD 100 HOME

     There you are...Ernestine is right where she was before.  
Believe it or not, we're actually getting somewhere.  Don't 
believe me?  Well, try this...

     REPEAT 5 [FD 150 BK 50 RT 72]

     Wow...that's a pretty weird pentagon!  But it shows you what 
we've been doing.  To draw a pentagon, Ernestine goes FD 100, 
turns RT 72.  Now you can see the angles much more clearly.  Try 
the same thing with the hexagon.

     REPEAT 6 [FD 150 BK 150 RT 60]

     When drawing a hexagon, Ernestine goes FD 100, turns RT 60 
on the outside.  That leaves an angle of ________ on the inside?
If you said 120, let's make you a big Gold Star!

     Look at your drawing of the pentagon with the diagonals.  At 
each corner, how many angles do you see?  I see three, how about 
you?  Are all the angles the same?  OK...so of that inside angle 
is 108, what are each of the three angles?  That's 108 divided by 
3 or 36, right?

     Now... take your pencil and ruler and draw along any one of 
the diagonal lines to make it go out beyond the pentagon...like 
Ernestine did went she went FD 150 BK 50.  Here you have the 
large angle outside the star and the small angle inside.  We 
already know the small angle is 36.  So what's the big angle?
That's 180 - 36 or...144.

     Now we're really getting somewhere!  So what angle do we 
need to draw a star?

     REPEAT 5 [FD 160 RT ______]

Now add this one...

     LT 36 REPEAT 5 [FD 100 RT 72]          
    
How about that!  There's the star inside the pentagon...just like 
the picture you drew on paper.

     But how'd Ernestine know the distance was 160?  Well, that's 
another lesson.  Why not see what you can do with the Star of 
David now?  If you look closely, you'll see there are two 
triangles in the Star.  Here's a hint.  If the side of the 
hexagon is 100, try 172 for the side of the triangle.
     
                             - 43 -               

     TO PENTAGON
     REPEAT 5 [FD 100 RT 72]
     END

     TO STAR 
     RT 36 REPEAT 5 [FD 160 RT 72]
     END

     TO HEXAGON
     REPEAT 6 [FD 100 RT 60]
     END

     TO STAR.OF.DAVID
     RT 30 TRI
     RT 90 FD 100
     LT 150 TRI
     END

     TO TRI
     REPEAT 3 [FD 172 RT 120]
     END
































                             - 44 -

CHAPTER 3.  VARYING VARIABLES



     TO BOXES
     REPEAT 4 [FD 60 RT 90]
     RT 90 PU FD 80 PD LT 90
     REPEAT 4 [FD 60 RT 90]
     END

     By now, you should know what this procedure will look like 
after it's been run.  What do you think?

     Sure...that's a procedure to draw two boxes side by side.

     But what if you wanted to draw 20 boxes?

     What if you want the boxes to be bigger?

     What if you want them smaller?

     In other words, what if you want to vary the size or the 
number of boxes?  No problem...this is where those things called 
"variables" come in.  A variable is something you put into a 
procedure so you can change it whenever you want.

     Yes, that does sound confusing.  So let's draw the boxes 
again.

     TO BOXES :SIZE
     REPEAT 4 [FD :SIZE RT 90]
     RT 90 PU FD :SIZE + 20 PD LT 90
     REPEAT 4 [FD :SIZE RT 90]
     END

     Bet you already know what the variable is, don't you?  It's 
the :SIZE.  

     Try it out.  Type...

     BOXES 20  

     BOXES 40  

     BOXES 60  

     BOXES 100

     When you type BOXES :SIZE, you tell the :SIZE variable to 
have a value of 20.  What about BOXES 60.  What's the value of 
:SIZE?


                             - 45 -

     Variables must always have a value.  They must also have the 
two dots in front.  Yes, that's a colon.  But in Logo, we call 
them "dots."  You'll find they can save you a lot of time and 
typing.  Take a look...

     Remember the TRI procedure?  Let's add a variable.

     TO TRI :N 
     REPEAT 3 [FORWARD :N RIGHT 90]
     END

     This shows that you can name variables just about anything 
you want.  Rather than call this one :SIZE, we call it :N.  But 
we still use the dots...we have to do that.

LOCAL AND GLOBAL VARIABLES

     LadyBug can write two kinds of variables: global and local.  
Global variables can be used by any procedure.  Take a look...

     TO SHAPES :N
     TRI :N
     SQUARE :N
     RECTANGLE :N
     END

Write procedures for a square and a rectangle using :N for the 
distance forward.

     TO SQUARE :N
     REPEAT 4 [FORWARD :N RIGHT 90]
     END

     TO RECTANGLE :N
     REPEAT 2 [FORWARD :N RIGHT 90 FORWARD :N * 2 RT 90]
     END

If you type SHAPES 50, each of the procedures will use 50 
wherever there is an :N. 

     Local procedures are "local" to the one procedure where it 
is used.  You write them like this...

     TO TRI
     LOCAL "N
     MAKE "N 100
     REPEAT 3 [FD :N RT 120]
     END

Go ahead.  Change your TRI procedure and then run the SHAPES 
procedure using SHAPES 50 again.  Now what's the picture look 
like?  Why?
   
                            - 46 -

RABBIT TRAIL #9.  Tangram Puzzles


     The tangram is a Chinese puzzle with seven shapes of 
different sizes.  We've made some procedures to draw these 
shapes.  Each uses the same variable, :SIDE...for example, try 
using 150 as the variable in each of these procedures.

     TO TRIANGLE.RT :SIDE            
     FD :SIDE
     RT 135
     FD :SIDE / SQRT 2
     RT 90
     FD :SIDE / SQRT 2
     RT 135
     END

     TO TRIANGLE.LT  :SIDE
     FD :SIDE
     LT 135
     FD :SIDE / SQRT 2
     LT 90
     FD :SIDE / SQRT 2
     LT 135
     END

     TO SQUARE.LT  :SIDE
     MAKE "SIDE1 :SIDE / ( 2 * SQRT 2 )
     REPEAT 4 [ FD :SIDE1 LT 90 ]
     END

     TO SQUARE.RT  :SIDE
     MAKE "SIDE1 :SIDE / ( 2 * SQRT 2 )
     REPEAT 4 [ FD :SIDE1 RT 90 ]
     END

     TO MED.TRI.RT  :SIDE
     FD 2 * ( :SIDE / ( 2 * SQRT 2 ) )
     RT 135
     FD :SIDE / 2
     RT 90
     FD :SIDE / 2
     RT 135
     END

     TO MED.TRI.LT  :SIDE
     FD 2 * ( :SIDE / ( 2 * SQRT 2 ) )
     LT 135
     FD :SIDE / 2
     LT 90
     FD :SIDE / 2
     LT 135
     END
                              - 47 -

     TO SMALL.TRI.RT  :SIDE
     FD :SIDE / 2
     RT 135
     FD ( :SIDE / SQRT 2 ) / 2
     RT 90
     FD ( :SIDE / SQRT 2 ) / 2
     RT 135
     END

     TO SMALL.TRI.LT  :SIDE
     FD :SIDE / 2
     LT 135
     FD ( :SIDE / SQRT 2 ) / 2
     LT 90
     FD ( :SIDE / SQRT 2 ) / 2
     LT 135
     END

     TO PARGRAM.LT  :SIDE
     REPEAT 2 [ FD :SIDE / ( 2 * SQRT 2 ) LT 45 FD :SIDE / 2 LT 135 ]
     END

     TO PARGRAM.RT  :SIDE
     REPEAT 2 [ FD :SIDE / ( 2 * SQRT 2 ) RT 45 FD :SIDE / 2 RT 135]
     END

     These procedures draw the different shapes to the right or 
to the left, whichever you want to use.  To give you an idea of 
what you can do with tangram shapes, try this procedure.

     TO TANGRAM  :SIDE
     SETH 90 TRIANGLE.LT :SIDE
     FD :SIDE SETH 0
     TRIANGLE.LT :SIDE
     FD :SIDE
     SETH 270
     SMALL.TRI.LT :SIDE FD :SIDE / 2
     SETH 225 MED.TRI.RT :SIDE
     SQUARE :SIDE FD :SIDE1
     PARGRAM :SIDE
     END

This procedure combines the different shape procedures into one 
big shape.  Which one?  You'll have to run the procedure to see.

WANT TO HAVE SOME FUN WITH TANGRAMS?

     Draw the tangram shapes on heavy paper or cardboard.  Then 
cut them out.  Put two triangles together.  What shape is do you 
get?


                              - 48 -

     Put the parallelogram and a small triangle together.  What 
shape is that?

     Can you make a triangle using five pieces of the puzzle?

     You'll find lots of puzzle books that have tangrams in them.  
But you don't really need those books, do you.  You can think up 
all sorts of shapes on your own.

     Why not have the computer think up some shapes for you?  
These might come out a bit crazy.  But who cares?  That's the fun 
of having the turtle do things for you.


     TO CRAZY.SHAPES  :SIDE
     SHAPES :SIDE
     MOVE :SIDE
     CRAZY.SHAPES :SIDE
     END

     TO SHAPES :SIDE          
     MAKE "SHAPE INTEGER RANDOM 10
     IF :SHAPE = 0 [TRIANGLE.RT :SIDE]
     IF :SHAPE = 1 [TRIANGLE.LT :SIDE]
     IF :SHAPE = 2 [MED.TRI RT :SIDE]
     IF :SHAPE = 3 [MED.TRI.LT :SIDE]
     IF :SHAPE = 4 [SMALL.TRI RT :SIDE]
     IF :SHAPE = 5 [SMALL.TRI LT :SIDE]
     IF :SHAPE = 6 [SQUARE.RT :SIDE]
     IF :SHAPE = 7 [SQUARE.LT :SIDE]
     IF :SHAPE = 8 [PARGRAM.RT :SIDE]
     IF :SHAPE = 9 [PARGRAM.LT :SIDE]     
     end

     TO MOVE :SIDE
     MAKE "MOVE INTEGER RANDOM 5     
     IF :MOVE = 0 [SETH HEADING + 45]
     IF :MOVE = 1 [SETH HEADING + 90]          
     IF :MOVE = 2 [FD :SIDE]
     IF :MOVE = 3 [FD :SIDE / 2]
     IF :MOVE = 4 [FD ( :SIDE / SQRT 2 ) / 2]
     END











                             - 49 -

     Now let's get back to that first TRI procedure and see what 
we can do with it.  How about a hexagon...with a global variable?

     TO HEXAGON :N
     REPEAT 6 [TRI :N RIGHT 60]
     END

     Be sure to tell the turtle how big to make the hexagon.


     Did you know that you can do just that in a procedure?  If 
not, try this...

     TO SPIDERWEB
     HEXAGON 30
     HEXAGON 40
     HEXAGON 50
     END

     Can you think of another way to write this procedure so that 
the turtle will do the same thing?  How about this...

     TO SPIDERWEB :N
     HEXAGON :N
     HEXAGON :N + 10
     HEXAGON :N + 20
     END

     Go ahead.  Type this procedure and then enter...

     SPIDERWEB 30

     Play around with this idea to see what it can do.  Make up 
some other shapes using variables to which you add numbers.

     Can you think of a way to use more variables in the 
SPIDERWEB procedure?  What about substituting a variable for 10?  
For 20?  For both?

     TO SPIDERWEB :N :X :Y
     HEXAGON :N
     HEXAGON :N + :X
     HEXAGON :N + :X * :Y
     END

     This is getting complicated.  Here you have three variables.

     :N  gives you the size of each side.

     :X  tells you how much to add to :N

     :Y  tells you to multiply :X by this number

                             - 50 -     

     After you've typed in this procedure, try this and see what 
happens.

     SPIDERWEB 30 10 2

     Does this look like the first spiderweb the turtle drew?  It 
should.  Take a look...

     TO SPIDERWEB 30 10 2
     HEXAGON 30
     HEXAGON 30 + 10
     HEXAGON 30 + 10 * 2
     END

This is fine when you want to make three hexagons that have sides 
of 30, 40, and 50.  But what if you want to do five hexagons?  
Seven hexagons?  Seventy hexagons?

CHANGING VARIABLES

     Either you do a lot of typing...or you find another command 
to help you out.  Maybe there's a command that will let you MAKE 
the variable whatever you want it to be.

     Does that give you a clue?  It should...take a look.

     TO SPIDERWEB :N
     HEXAGON :N
     MAKE "N :N + 10
     SPIDERWEB :N
     END

     Let's trace this procedure.  When you type SPIDERWEB 30, the 
first thing the turtle will do is draw a hexagon with sides of 
30.  Then the turtle reads the next line...

     MAKE "N :N + 10

     This says to MAKE the object "N have the value of :N + 10...or 
MAKE "N 30 + 10, or 40.

     Now the turtle reads the next line as SPIDERWEB 40.  Do you 
know why?

     The turtle then draws a hexagon with sides of 40...and then 
reads the next line.  What happens to N there?  You can see what 
happens by watching the turtle draw lots of hexagons. Soon it 
will fill the screen with them.

     Of course...this raises another question.  How can you get 
the turtle to stop?


                             - 51 -

     One way to stop the turtle is to press F1.  This stops the 
turtle wherever she is.  But wouldn't it be better if you could 
get the turtle to stop after she's finished doing the last 
hexagon.

     Well...there is a way.  You just tell the turtle that IF 
the last hexagon was as big as you want the spiderweb to be, stop 
drawing.

     TO SPIDERWEB :N 
     IF :N > 100 [STOP]
     HEXAGON :N
     MAKE "N :N + 10
     SPIDERWEB :N
     END

     Look at that first line in the procedure.  When the turtle 
reads this line, it learns that if :N is greater than 100, stop 
drawing.  

         That thing that looks like an arrowhead after 
         the :N >  is the symbol for "greater than."  
         It means that if the value of :N is greater 
         than 100, then STOP. 

          If > means "greater than," what does that 
         other arrow symbol -- < -- mean?  You guessed 
         it.  It means "less than."  An easy way to 
         remember which symbol is which is that the 
         arrow always points to the smaller value.

         IF :N > 100 means that the value of :N must 
         be larger than 100...at least 101.

         IF :N > 100 means that the value of :N must be 
         less than 100...at least 99.
 
For our example, we picked 100 as a place to stop.  You can 
select your own stopping point.  Or you can make the stopping 
point another variable.  How would you do that?

     Go ahead.  Give it a try.  But remember, if you're going to 
use a variable like this, you have to put it in the procedure 
name.     

     TO SPIDERWEB :N  ____
     IF :N > ____ [STOP]
     HEXAGON :N
     MAKE "N :N + 10
     SPIDERWEB :N ____
     END     


                             - 52 -

     When you've finished with your spiderwebs, why not try 
adding variables to your procedures for drawing other shapes?  
See what you can do with squares, rectangles and things.  

POLYGON PROCEDURE

     Before we leave variables, let's think some more about 
drawing shapes using variables and The Rule of 360.

     TO SHAPE :SIDE
     REPEAT _____ [FORWARD :SIDE RIGHT 360 / _____]
     END

     When you fill in the blanks with the right numbers, you can 
draw just about any shape.
     
     TRIANGLE:      REPEAT 3 [FORWARD :SIDE RIGHT 360 / 3]
     SQUARE:        REPEAT 4 [FORWARD :SIDE RIGHT 360 / 4]
     PENTAGON:      REPEAT 5 [FORWARD :SIDE RIGHT 360 / 5]
     HEXAGON:       REPEAT 6 [FORWARD :SIDE RIGHT 360 / 6]
     OCTAGON:       REPEAT 8 [FORWARD :SIDE RIGHT 360 / 8]

     How about this...

     TO POLYGON :SIDE :REPEATS
     REPEAT :REPEATS [FORWARD :SIDE RIGHT 360 / :REPEATS] 
     END


     Once you've played with this procedure a bit, write one to 
draw all of the shapes up to a circle.  Sure you can do it.  Give 
it a try.

     TO POLYGONS :SIDE :REPEATS
     REPEAT :REPEATS [FORWARD :SIDE RIGHT 360 / :REPEATS]
     MAKE "REPEATS :REPEATS + 1
     POLYGONS :SIDE :REPEATS
     END


     Have you noticed something funny about the procedures in 
this section?  

     Look at the SPIDERWEB procedure again...and the POLYGONS 
procedure.  The last line is the same as the name of the 
procedure, right?

     What happens when you run these procedures?  They repeat 
themselves, right?  Seems like the procedure is going in a 
circle.  Well...this is what they call tail-end recursion...and 
we're going to learn about it in the next chapter.

     
                             - 53 -

CHAPTER 4.  RECURSION


     Recursion is when a procedure uses itself as part of the 
solution.

Say what?

Yes, strange as that seems, it's correct.  A recursive procedure 
is one that calls itself as part of the total solution. Here's a 
fun recursive procedure, even though it really isn't Logo.

     TO GET.THROUGH.LIFE
     GET.THROUGH.TODAY
     GET.THROUGH.LIFE
     END

Think about it for a moment.  This says that to get through life, 
you have to get through today.  Once you are through today, you 
have to move on, right?  But where?  You can't go backward.  You 
can't stop time.  You have to get through life.  But to get 
through life, you have to get through today...and so on and so on 
and so on and so on.

Awfully simple...or simply awful.

TAIL-END RECURSION

     Yes, recursion is confusing.  So let's try it with something 
we know something about.

     TO MAZE :N
     FORWARD :N
     RIGHT 90
     MAKE "N :N + 5
     MAZE :N
     END

Here's another example of what we call "tail-end recursion."  To 
see just how this works, type 

     MAZE 20 

Now watch what happens.  The turtle goes forward 20 steps and 
then turns right 90 turns.  Then the procedure tells :N (that's 
20 to us) to become :N + 5 (that's 25 to us now).  Then the 
procedure says

     MAZE 25

It starts all over again.  MAZE 25 becomes MAZE 30.  MAZE 30 
become MAZE 35, and on and on and on.

                             - 49 - 

The screen soon looks something like this, and it just keeps on 
going, gradually filling up the screen.

        ____________________________
        |   _____________________   |
        |   |   ____________    |   |
        |   |   |   _____   |   |   |
        |   |   |   |   |   |   |   |
        |   |   |_______|   |   |   |
        |   |_______________|   |   |
        |_______________________|   |
     _______________________________|    

Of course, we can put a STOP in there if we want.  

     TO MAZE :N
     IF :N = 100 [STOP]
     FORWARD :N
     RIGHT 90
     MAKE "N :N + 5
     MAZE :N
     END

Now, when :N equals 100, the procedure stops.

EMBEDDED RECURSION

     You might think that recursion is just like a loop...that it 
just seems to go around in circles.  Well...yes and no.  
Sometimes things aren't what they seem to be.  To learn more 
about recursion, let's take a look at another procedure that uses 
"embedded recursion."

     TO TEST.RECURSION :N
     PRINT [IS THIS RECURSION?]
     MAKE "N :N + 1
     IF REQUEST = "YES [TEST.RECURSION :N]
     PRINT :N
     END

Type this in and run it.  This time we're using the variable "N" 
as a counter.  Watch and see.  To start the procedure, type

     TEST.RECURSION 0  (We want the counter to start with 0.)

The first thing you see on the screen is the question

     IS THIS RECURSION?

     REQUEST tells the LadyBug to stop and wait for you to type 
an answer.  Type YES.  Then we come to a test.  If the word you 
typed was YES, then the procedure calls itself.  What happens?  

                             - 55 -

     You guessed it, there's that question again...

     IS THIS RECURSION?

     Type YES a few times when you see the question.  Then type 
NO.  What happens this time?

     When you type N, the procedure comes to the test.  This time 
the word you typed doesn't match "Yes" and so the computer reads 
the next line

     PRINT :N

     WOW...what happened then?

     Why were so many numbers printed?  Well, that's what makes 
recursion different from program loops.

     When you first look at this procedure, it seems like it is 
going to go around in a loop.  Everytime it passes the MAKE "N :N 
+ 1 line, the counter is going to add 1. Then, when you type NO
instead of YES, you'd thing the procedure would print the 
current value of N.

     Well...that's the way programming loops work but that isn't 
the way recursion works.

     Let's look at this again.  You'll need some blank paper, a 
pencil, and scissors for this one.

     Fold the paper in half. Then fold it in half again...and 
again...then one last time.  Crease the edges good and then open 
up your piece of paper. 

     Cut the paper along the folds.  You should end up with 16 
small pieces.  Now number these "pages" from 1 to 16.  Write a 
small number down at the bottom of the page...like a 16-page 
book.

-------------    -------------    -------------    -------------
|           |    |           |    |           |    |           |
|           |    |           |    |           |    |           |
|           |    |           |    |           |    |           |
|         1 |    |        2  |    |         3 |    |         4 |
-------------    -------------    -------------    -------------

     Now get your pencil ready and run the TEST.RECURSION procedure.

     TEST.RECURSION 0

     First you see the question on the screen.  You don't see 
anything when the computer reads the line, MAKE "N :N + 1.  

                             - 56 -

     When the computer comes to the test line, what does N equal?  

     That's 0 + 1 = 1.  So write a big 1 on your first piece of 
paper and put that piece off by itself..something like this..

-------------  
|    /|     |  
|     |     |  
|    _|_    |  
|         1 |  
-------------  

     Type YES and what happens?  The question appears on the screen 
and :N becomes :N + 1.  In other words, :N becomes 1 + 1 or 2.  
Write 2 on your second piece of paper and put that on the pile 
with your first piece...the one with the 1 on it.

     Type YES again.  What does N become now?  Write 3 on the next 
piece of paper and put that piece on the number pile.  Do this 
again a three more times, writing the new number for :N each time.  

     Now, when type NO, what happens on the screen?  You see a 
list of numbers counting backward, right?  From 6 back to 1.

     You should have two stacks of paper now.  You should have 
some blank pages left over in one stack, pages 7 to 16.  The 
other stack has pages 1 to 6.  Each page has a big number written 
on it.

     Now put the pages back in order from 1 to 16.  

     So what do you do?  You put page #6 with the big number 6 on 
it, on top of page 7.  You put page #5 on top of page #6, page #4 
on top of page #5, and so forth until you have all the pages back 
in a single stack again.

     OK!  Picture the memory in your computer like that stack of 
pages.  LadyBug Logo gives you 40 pages to use.  If you want to 
test that out, run the TEST.RECURSION procedure again.  To make 
it easier, change the test line to

     IF RQ = "Y [TEST.RECURSION :N]

Now when you see the question, "Is this recursion?" just type Y.  
Keep count of the number of times you hit the Y key.  What 
happens when you reach 40.

     You get an error message...  

          ==> Procedure nesting is too deep



                             - 57 -

TOPLEVEL

     Think about what you just discovered.  Now...what do you 
think the LadyBug primitive TOPLEVEL does?

     TOPLEVEL brings you to the top of the memory stack.  Let's 
take a closer look.  LadyBug Logo reads what you type into the 
computer, one line at a time.  

SPECIAL NOTE:  When we talk about LadyBug reading a line or 
               procedure, we really mean that LadyBug reads the 
               line and does what it says.  We'll talk more about 
               this later.

     When you tell LadyBug to read a procedure, it reads 
that procedure one line at a time.  When a line in your procedure 
tells LadyBug to read another procedure, LadyBug has to stop, 
find the other procedure, read it, and then return to where it 
left off in the first procedure.  This is where the "stack" comes 
in real handy.  Let's take a look.

     TO TEST.RECURSION :N
     PRINT [IS THIS RECURSION?]
     MAKE "N :N + 1
     IF REQUEST = "YES [TEST.RECURSION :N]
     PRINT :N
     END

     When you load this procedure into memory, LadyBug starts at 
Toplevel.  Toplevel means there is nothing on the stack; LadyBug 
is at level 0.  Now you know why we tell :N to equal 0 when you 
start the procedure with TEST.RECURSION 0.  As LadyBug reads the 
procedure, there is one procedure on the stack.  When it comes to 
the test line...

     IF REQUEST = "YES [TEST.RECURSION :N]

If REQUEST equals YES, LadyBug stops and reads the new procedure 
name.  Remember, this is not the same name that you typed.  The 
name is now TEST.RECURSION 1, not TEST.RECURSION 0.

     LadyBug keeps reading.  It comes to the test line again.  If 
you answer, "Yes," she reads the "new" procedure as 
TEST.RECURSION 2.  Each time it reads the procedure, it moves to 
another page on the stack...just like you did when you wrote big 
numbers on each page.

     LadyBug Logo uses part of your computer's memory for this 
stack.  It also uses the stack to remember the values of 
variables you assign.  Since all of this has to fit into "40 
pages," don't let your procedures get too complicated.


                             - 58 -

RABBIT TRAIL #10. Amazing Mazes


     Remember the MAZE procedure.  This is a great example of 
tail-end recursion.

     TO MAZE :NUM
     IF :NUM > 120 [STOP]
     FD :NUM RT 90
     MAZE :NUM + 10
     END

     This is a little bit different than the other MAZE procedure 
but it does the same thing.  Type it in and try it.

     Now look at this procedure.

     TO AMAZE :NUM
     IF :NUM > 120 [STOP]
     AMAZE :NUM + 10
     FD :NUM RT 90
     END

     Here's an example of "embedded" recursion.  Will this 
procedure be the same as the MAZE procedure or will it be 
different?  Try to picture what it will look like before you run 
it.

     Think about how recursion works; about how it reads and acts 
on procedures.  Let's start with :NUM as 50.  Since 50 is not 
larger than 120, LadyBug goes to the next line.  AMAZE :NUM + 10
means that we now have AMAZE 60.  Each time the Ladybug starts 
reading the procedure, it puts the procedure on a "page" of the 
memory stack.  It will keep going, reading pages for AMAZE 50, 
60, 70, 80, 90, 100, 110, and finally 120.  Then it stops.  

     As LadyBug reads "puts the pages back in order," she sends 
the turtle FD 120, RT 90...then FD 110, RT 90...FD 100, rt 
90...back to where she started...FD 50, RT 90.

     Here's another example of embedded recursion to explore. 

     TO TOWER  :SIZE
     IF :SIZE < 0 [STOP]
     SQUARE :SIZE
     TOWER :SIZE - 10
     SQUARE :SIZE
     FD :SIZE
     END

     TO SQUARE :SIZE
     REPEAT 4 [FD :SIZE RT 90]
     END
                             - 59 -

     They say a picture is worth 10,000 words.  Maybe this 
picture will help you understand how recursion works compared to 
programs that loop.  Let's say we start with MAZE 50.


 _____________________
| TO MAZE :N         | <------  MAZE 50  
| IF :N = 100 [STOP] |        | 50 doesn't = 100 so we continue
| FD :N RT 90        |        | The turtle goes FD 50 RT 90
| MAZE :N + 5 \      |--------| The procedure doesn't loop back 
| END        |  \    |          to the top.  It calls itself again.
|____________|    \ _|
             |      \
             |        \  
             |__________\_________                 
             | TO MAZE :N         |   MAZE 55   
             | IF :N = 100 [STOP] |   55 doesn't = 100
             | FD :N RT 90        |   FD 55 RT 90
             | MAZE :N + 5 \      |             
             | END        |  \    |             
             |____________|    \ _|
                          |      \
                          |        \
                          |__________\__________
                          | TO MAZE :N         |  MAZE 60
                          | IF :N = 100 [STOP] |
                          | FD :N RT 90        |  FD 60 RT 90
                          | MAZE :N + 5 \      |             
                          | END        |  \    |             
                          |____________|    \ _|             
                                       |      \ 
                                       |        \
                                       |__________\_________
                          MAZE 65      | TO MAZE :N         |
                                       | IF :N = 100 [STOP] |
                          FD 65 RT 90  | FD :N RT 90        |
                                       | MAZE :N + 5        |
                                       | END                |
                                       |____________________|


     The procedure will continue "calling itself" until :N = 100.  
Then it will stop.                                           

     Rather than loop back to the beginning of the procedure as 
shown at the top of the stack, recursion moves through the memory 
stack one page at a time.  On the next page, you'll see how 
recursion helps make television and the movies more exciting.
     




                             - 59 -

FRACTALS

     Fractals were once thought to be math monsters.  No one 
could figure out what to do with them.  But thanks to computers, 
we now know that these recursive monsters help make beautiful 
computer graphics.

     Rather than try to explain Fractals, let's look at how they 
work.  Here's a procedure from the LadyBug Logo files.  

     TO C :SIZE :LEVEL
     IF :LEVEL = 0 THEN FD :SIZE ELSE STOP
     C :SIZE  :LEVEL - 1 RT 90
     C :SIZE :LEVEL - 1 LT 90
     END

     If you look at the procedure, you see that :SIZE is the 
variable used by FD.  :LEVEL is a bit confusing, so let's watch 
it work first.  Enter...

     C 10 8  

Wow...that's some pattern. Now enter DRAW and try...

     C 20 3     
     
OK...add this short procedure.  Then you can see how Ernestine 
builds such complicated pictures.

     TO SEE 
     C :SIZE :LEVEL WAIT 10 DRAW
     MAKE "LEVEL :LEVEL + 1  SEE
     END

     TO WAIT :T
     IF :T = 0 [STOP]
     WAIT :T - 1
     END

     MAKE "SIZE 10
     MAKE "LEVEL 0

     Hey!  Wait a minute...there's no procedure there at the end.  
How can that be?

     Well...this is a new trick.  You can tell the LadyBug what 
your variables will be without writing a procedure.  Let's try it 
out.  First, type ERASE ALL to get everything out of memory.  Now,
enter LOAD "C.  When you see the question mark to the left of the 
screen, add the SEE procedure and the two variable statements.  
Then type SEE. 

     There you are!  You're watching fractals in action.
                                  - 61 -

     Before we start looking at fractals, try one more thing.

     TO SEE 
     C :SIZE :LEVEL + 1
     WAIT 10 DRAW SEE
     END

     Why doesn't this procedure work like the first one?  What's 
the difference?  What makes this work differently?  After you 
figure this out, we'll talk about fractals a bit more.

     To help figure out fractals, write the C procedure on a 
piece of paper.  Change the WAIT variable to 15 or 20...long 
enough so that you can see the changes that were made from the 
last time it ran.  Another thing to do is change the LEVEL 
variable to 5 or 6...large enough so you can watch how the 
procedure works.  The higher the level, the more complex the 
picture.

     Imagine what the C procedure would be like with some color 
added.  If you want to try that, take a look at Chapter 8.  Then 
edit the procedure to add some color and watch what happens.

     You'll find some other fractal procedures on the LadyBug 
Logo diskette...SNOWFLAKE, HILBERT, DRAGON, and others.  Take a 
look at these.  Play around with different sizes and levels.  
With a little imagination, you'll begin to see how computer art 
is generated.

FACTORIALS

     Another very common use of recursion is in calculating 
factorials.  Factorial 5 is just another way of saying...

     5 * 4 * 3 * 2 * 1  =  120

the typical Logo procedure is like this...

     TO FACTORIAL :NUM
     IF :NUM = 1 [OUPUT :NUM]
     OP :NUM * ( FACTORIAL :NUM - 1 )
     END

     The LadyBug doesn't like working on several things at once.  
So we have to change this a bit.  This procedure works accurately 
on numbers up to 7.  The LadyBug can't handle numbers bigger than 
32767.

     TO FACTORIAL :NUM
     IF :NUM = 1 [OUPUT :NUM]
     MAKE "FAC FACTORIAL :NUM - 1 
     OP :NUM * :FAC
     END
                             - 62 =

CHAPTER 5. SUPERPROCEDURES, SUBPROCEDURES, AND SUCH


     

     Enough of this stuff.  It's time to get back to some fun.

     Let's tessellate!  Tessellations can be lots of fun...real 
brain teasers.  But what's a tessellation?

TESSELLATIONS AND OPTICAL ILLUSIONS

     You see tessellations all over the place.  They're the 
patterns you see in wallpaper, in tile floors, in blankets...even 
in clothes.  Strictly speaking, tessellations are patterns made 
by repeating one or more shapes over and over again in what seems 
like an endless pattern.

     Some tessellations are optical illusions...they look like 
something they are not.  Here's a long procedure that uses 
diamond shapes to make a strange geometric pattern.  It's 
long...but it's an interesting picture.

     TO PATTERN
     RIM INSIDE BLOCK
     END

     TO RIM  
     START SIDE3 ADD2 MOVE4
     SIDE3 ADD2 MOVE4 SIDE3
     ADD2
     END

     TO START 
     PU BK 103 LT 60 FD 16 PD
     END

     TO SIDE3 
     DIAMONDS MOVE2 DIAMONDS MOVE2 DIAMONDS
     END

     TO ADD2  
     MOVE3 DIAMONDS MOVE3 DIAMONDS
     END

     TO MOVE3  
     PU FD 16 RT 60 FD 56 LT 60 PD
     END

     TO DIAMONDS  
     DIAMOND 8 MOVE DIAMOND 24 MOVE DIAMOND 40
     END

                             - 63 -

     TO DIAMOND :N
     REPEAT 2 [FD :N RT 60 FD :N RT 120]
     END

     TO MOVE  
     PU RT 60 BK 8 LT 60 BK 8 PD
     END

     TO INSIDE 
     MOVE5 SIDE2 ADD1 MOVE4 SIDE2 
     ADD1 MOVE4 SIDE2 ADD1
     END

     TO MOVE5 
     PU RT 60 BK 24 RT 60 FD 16 LT 60 PD
     END

     TO MOVE4 
     PU FD 24 RT 60 FD 40 RT 60 FD 16 PD
     END

     TO SIDE2 
     DIAMONDS MOVE2 DIAMONDS
     END

     TO MOVE2  
     PU FD 56 RT 60 FD 16 LT 60 PD
     END

     TO ADD1  
     MOVE3 DIAMONDS
     END

     TO BLOCK  
     MOVE6 DIAMONDS MOVE7 DIAMONDS MOVE7 DIAMONDS
     END

     TO MOVE6 
     PU RT 60 FD 16 RT 60 FD 16 LT 60 PD
     END

     TO MOVE7  
     PU FD 24 RT 60 FD 40 RT 60 FD 16 PD
     END


     To see what all this typing is about, type PATTERN.

     Pretty neat, huh?




                             - 64 -

     This long procedure introduces you to another idea... 
superprocedures and subprocedures.  A superprocedure is one like 
PATTERN, RIM, INSIDE and and others.
     
     TO PATTERN
     RIM INSIDE BLOCK
     END

     TO RIM  
     START SIDE3 ADD2 MOVE4 SIDE3 ADD2 MOVE4 SIDE3 ADD2
     END

     TO INSIDE 
     MOVE5 SIDE2 ADD1 MOVE4 SIDE2 ADD1 MOVE4 SIDE2 ADD1
     END

These procedures don't do anything by themselves, do they?  But 
they do make a lot happen.  That's because they call other 
subprocedures.  Those are the ones like the MOVE procedures, and 
DIAMOND.

     Think what it would be like if you had to type in every move 
the turtle made to draw that optical illusion?  That would sure 
be a lot of typing.

     Superprocedures help you organize your thinking when you're 
putting together long, complicated procedures.  They can also 
save you a lot of work.  Take a look...

     TO CIRCLE :N :A
     REPEAT 360 [FD :N RT :A]
     END

Here's a simple circle procedure we can use to draw circles of 
many different sizes.  Now let's see what we can do with them.

     TO SLINKY
     CIRCLES
     END

     TO CIRCLES
     CIRCLE 5 5 FD 20 CIRCLES
     END

     TO SPAGHETTI
     CIRCLE 5 10 CIRCLE 4 10
     CIRCLE 3 10 CIRCLE 2 10
     TR SPAGHETTI
     END

     TO FLOWER
     REPEAT 12 [CIRCLE 5 5 TR]
     END
                             - 65 -

     TO TR
     RT 30
     END

     Now...see what you can dream up.  If you need a little help 
getting started, see what kind of vines you can grow.

     TO VINE  
     HALFVINE
     OTHERHALF.VINE
     END

     TO HALFVINE  
     FD 6 RT 30 REPEAT 6 [FD 4 RT 20]
     RT 60 REPEAT 6 [FD 4 RT 20] RT 30
     END

     TO OTHERHALF.VINE  
     FD 6 LT 30 REPEAT 6 [FD 4 LT 20]
     LT 60 REPEAT 6 [FD 4 LT 20]
     END
































                             - 66 -

CURVES FROM STRAIGHT LINES

     Here's another optical illusion that can be lots of fun.  
Let's make some curves from straight lines.  Yes...that's 
right...curves from straight lines.  If that doesn't make sense, 
type this procedure and then use 50 for :D and 10 for :A.

     TO FAN :D :A
     IF :D < 0 [STOP]
     FD :D BK :D - 5 LT :A
     FAN :D - 3 :A
     END

Get the idea!  Now play with :D and :A, using different numbers.  
What would happen if you made :A bigger?  Smaller?  If it changed 
each time the procedure was run...like this.

     TO FAN  :D :A
     IF :D < 0 [STOP]
     FD :D BK :D - 5 LT :A
     FAN :D - 3 :A + 1
     END

What differences do you see?  What would happen if you changed :A 
+ 1 to :A - 1?

     So far, the fan has folded out to the left.  Let's label 
that procedure FAN.LT.  Do you have to type the whole procedure 
in again?  No, that's what LadyBug's editor is for.  Just type 
ED "FAN to get to the editor.  Change FAN to FAN.LT in the title 
and in the next to last line.  When you press F9 to get out of 
the editor, you'll have two procedures...FAN and FAN.LT.

     TO FAN.LT  :D :A
     IF :D < 0 [STOP]
     FD :D BK :D - 5 LT :A
     FAN.LT :D - 3 :A
     END

Now let's change the procedure to go to the right.  Do this in 
the editor to save yourself some time.  Change FAN.LT to FAN.RT 
in the title and the next to last line.  Then you'll have three 
FAN procedures...FAN, FAN.LT, and FAN.RT.

     TO FAN.RT  :D :A
     IF :D < 0 [STOP]
     FD :D BK :D - 5 RT :A
     FAN.RT :D - 3 :A
     END


     Try them out.  See what happens.

                             - 67 -

     What would happen if we put these procedures together into a 
superprocedure.  First we have to write two "START" procedures.

     TO START 
     PU HOME PD
     END

     TO START2 
     PU HOME RT 180 PD
     END

     Now we can put all of these together for some interesting 
patterns. 

     TO SWIRL  :D :A
     START FAN.LT :D :A  START 
     FAN.RT :D :A START2 
     FAN.LT :D :A START2 
     FAN.RT :D :A
     END
     
Here's another twist on our fan procedures.  Before you type this 
one and run it, can you describe what the picture would look 
like?

     TO START :H
     PU HOME RT :H PD
     END

     TO TWIST :D :A :H
     START :H FAN.LT :D :A
     START :H FAN.RT :D :A
     TWIST :D :A :H + 90
     END



















                             - 68 -     

RABBIT TRAIL #11.  Logo String Art


     String and wire art is a great way to explore curves from 
straight lines both on and off the computer.  And a great way to 
experiment with string art is to get hold of a shoe box.  First, 
we're only going to use the top of that box.  But don't get rid 
of the other part.  We'll use that a little later.

     The first thing you want to do with your boxtop is paint the 
inside.  Use black, dark blue, or any other dark color.  Spray 
paint will make a nice smooth finish on the boxtop.  But if you 
don't have spray paint, don't worry about it.  A brush will do 
the job just fine.

     OK!  Now that you have your boxtop painted, you're going to have 
to design a nice even pattern around the outside of the top. This 
pattern will mark the places where you'll sew your curves from 
straight lines.

     Here's some procedures to get you started.

        TO PATTERN :R :D :M
        REPEAT :R [MARK1 :M RT 360/R]
        END

        TO MARK
        LT 90 FD 2 BK 4 FD 2 RT 90
        END

        TO MARK1 :M
        REPEAT :M [FD :D / :M MARK]
        END

     Try some different numbers for the variables and see what 
you get.

     PATTERN 4 100 10
     
     PATTERN 3 120 8

     PATTERN 6 60 6

     How could you use these procedures to make a pattern for the 
edge of your boxtop?

     That pattern would have to be a straight line, wouldn't it;  
a straight line with marks at every 10 or 20 steps -- as many 
steps as you want.  When :R in PATTERN is 4, you get a square, 
right?  When it is 3, you get a triangle.  What would happen if 
:R was 2? 


                             - 69 -

Try it out...

        PATTERN 2 100 10

Seems to work, doesn't it.

     If we turn that line on it's side, we can make it longer.  
So turn the turtle 90 turtle turns.  Then enter...

        PATTERN 2 500 50

Then print the line out on your printer, cut it out, and glue it 
to the outside of your boxtop.  You'll probably have to print 
several copies of the line to get all the way around the boxtop.

     Now you're ready to start making your string art in the 
boxtop.  Use different colors and your imagination for some 
great patterns.  

     The PATTERN procedure is fine for regular shapes.  But how 
does this help with a boxtop?  What kind of shape do we need to 
make for the top of a shoe box?

        That's easy!
 
        A rectangle, of course!!!

        One way to make a rectangle is to use the MARK1 procedure 
to move up one side.  Then we need to turn right and go forward 
twice the distance, or REPEAT 2 [MARK1 :M].  So let's call that 
BOXTOP and make a rectangle.

        TO BOXTOP :D :M
        REPEAT 2 [MARK1 :M RT 90 REPEAT 2 [MARK1 :M] RT 90]
        END

Now we have a rectangle with marks for our stringart patterns.

     All of this leaves a big question.  Is there a procedure 
which will create string art in most any shape?

     This one is not a glamorous as some others I know you can 
write.  But this one explains how the idea works pretty well.
        
        TO CURVE :T :GAP :X1 :Y1 :X2 :Y2
        IF :T = 0 [STOP]
        PU SETXY :X1 :Y1 PD
        SETXY :X2 :Y2
        MAKE "X1 :X1 + :GAP
        MAKE :Y2 :Y2 + :GAP
        CURVE :T - 1 :GAP :X1 :Y1 :X2 :Y2
        END

                             - 70 -

     WOW!  Does that ever have a lot of variables!  Wonder what 
they all mean?

     This is a procedure to draw a series of straight lines 
within a shape made by the PATTERN procedure or by the BOXTOP 
procedure.

        :T      This is the number of times the procedure
                will draw a line.  If T equals 10, then 10
                lines will be drawn.

        :GAP    This is the distance between each line.

        :X1     These are the coordinates of one end
        :Y1     of the line.

        :X2     These are the coordinates of the other
        :Y2     end of the line.

What about using circle patterns?

     TO PATTERN :R :D
     REPEAT :R [FD :D MARK RT 360 / :R]
     END

     TO MARK 
     LT 90
     FD 2 BK 4 FD 2
     RT 90
     END

     TO FB :N
     FD :N BK :N
     END



     Now is the time for you to explore string art on and off the 
computer.  Make up all sorts of patterns; first on the computer, 
and then off the computer.  Then change it around -- do it off 
the computer, and then on the computer.  In fact, I bet you can 
make a prettier pattern off the computer than you can on the 
screen.  What do you think?
 
     But what about the bottom of the box?  What can you do with 
that?

     Well, why not start doing string art in three dimensions.  
Make a nice, neat curved design on a piece of paper.  Transfer 
that design to the top and bottom of the box.  Then start 
experimenting with different 3-D string art designs.  


                             - 71 -

     Did you notice some new commands in the procedures in this 
chapter?  

     What is SETXY mean?

     What is SETX?

     What are coordinates?

     Looks like it's time to explore something new.











































                             - 72 -

CHAPTER 6. TURTLE POSITIONS
       

     So far, we've moved the turtle around the screen using 
direction commands: FORWARD, BACK, LEFT, RIGHT. Well, there's 
another way to do this that opens up all sorts of new things to 
do.

TURTLE HEADINGS

     When you want the turtle to move from home up to the right, 
you can tell her go RIGHT 45 FD 50.  Another way to do that is to 
tell the turtle to set her heading to 45 and then go forward 50 
steps.

     SETHEADING 45 FD 50

Or you can use shorthand...

     SETH 45 FD 50 BK 50

     When you typed SETH 45, what direction did the turtle turn?
If you type SETH -45 FD 50 BK 50, what do you think would happen?  
Go ahead...try it and see.  OK...now type SETH 45 again.  What 
happened?  Hmmmm?  This is interesting.  Now type SETH 45 FD 50 
BK 50 again.  What happened this time?

     Well, it seems like you can use the SETH command to turn the 
turtle.  But it sure doesn't act like the RIGHT and LEFT 
commands.

     If you ever want to know what heading the turtle is on, type

     PRINT HEADING

     Remember the string clock you made a while ago; the one you 
made with a piece of board and some nails?  This is a good tool 
for learning about headings.

     What heading is at 12:00?  3:00?  6:00?  9:00?

     Get the idea?  Turtle headings follow the hands of the 
clock.  The heading at 12:00 is zero...at 3:00, it's 90...at 6:00, 
it's 180...and at 9:00, it's 270.  

     This isn't to say that I can't move counter clockwise...to 
the left.  You've already seen what happens when you typed 

     SETH -45.

     What time would it be at SETH -90?  SETH -180?  SETH -270?

     
                             - 73 -

     We'll use the headings a bit more later.  But first, take a 
look at this position screen.

-----------------------------------------------------------------
|-250,150                     0,150                      250,150|
|                              |                                !
|                              |                                |
|                              |                                |
|                              |                                |
|                              |                                |
|                              |                                |
|                              |                                |
|-250, 0 ---------------------0,0-------------------------250,0-|
|                              |                                |
|                              |                                |
|                              |                                |
|                              |                                |
|                              |                                |
|                              |                                |
|                              |                                |
|-250,-150                    0,-150                    250,-150|
-----------------------------------------------------------------
X AND Y COORDINATES

     Imagine this screen drawing with 500 columns drawn on it and 
300 rows.  Columns go up and down.  Rows go from side to side.  
To find a position, you'd have to know which column and which row 
to pick.

     This is exactly what you can do using the X and Y 
coordinates.  The X lines are the rows going side to side.  Y 
lines are the columns going from top to bottom.  If you'd like to 
see this type of grid on the screen, use this procedure...

     TO GRID 
     HT CS PRINT [Let's take a look at x-y coordinates.]
     WAIT 5 CS G 120 GRAPH
     TYPE [The turtle is HOME at 0,0.]
     END

     TO G  :R
     REPEAT 25 [D] RT 90 REPEAT 15 [D]
     END

     TO D  
     RT 90 FD 10 LT 90 BK 5 FD 5 RT 90 FD 10 LT 90 FD 2 BK 7 FD 5
     END

     TO GRAPH  
     PC 1 XLINE -250 LASTX YLINE 150 LASTY PU HOME PD ST PC 3
     END


                             - 74 -

     TO XLINE  :SIZE
     PU SETXY :SIZE 150 PD SETXY :SIZE -150 IF :SIZE = 250 [STOP]
     XLINE :SIZE + 20 HT
     END

     TO YLINE  :SIZE
     PU SETXY -250 :SIZE PD SETXY 250 :SIZE 
     IF :SIZE = -150 [STOP] 
     YLINE :SIZE - 20 HT
     END

     TO LASTY  
     PU SETXY -250 -150 PD SETXY 250 -150
     END

     TO LASTX  
     PU SETXY 250 150 PD SETXY 250 -150
     END

     TO WAIT  :T
     IF :T = 0 [STOP]
     WAIT :T - 1
     END


     Home is at x-coordinate 0 and y-coordinate 0.  In Logo we 
use the shorthand names...

     XCOR

     YCOR

     Type DRAW.  Then type PRINT XCOR.  What happened?

     Hmmmmm.  Very interesting.  What do you think you need to do 
to set another x-coordinate?  Give yourself a Gold Star if you 
said SETX...not SET XCOR.  Go ahead...try it.

     SETX _____

     SETX _____

Now try moving the turtle up and down.  What's the command?

     SETY _____

     SETY _____

     I bet you've already guessed that you can combine these two 
commands.  Sure...you've already done it.

     SETXY _____ _____

                             - 75 -

     That's right.  You have to type both the X position and the 
Y position with the SEYXY command.  Try a few.

     SETXY _____ _____

     SETXY _____ _____

     SETXY _____ _____


SPECIAL NOTE:  Some versions of Logo don't have a SETXY command.  
               They use SETPOS instead.  If that's what your 
               version uses, try this command:

                    TO SETXY :X :Y
                    SETPOS SE :X :Y
                    END

                Now you can use the LadyBug's commands.


     Was the pen down when you typed these commands?  What 
happened?  Did you end up with a crazy drawing on the screen?  
If the pen was up, put it down and then do a few more SETXY 
commands.

     There...see what you can do with these coordinate commands? 
You can even use them to make drawings.

     TO WHAT.IS.IT
     DRAW PU SETXY 5 25 PD WHAT1 WHAT2 WHAT3
     END

     TO WHAT1   
     SETXY 25 25 SETXY 30 25 
     SETXY 35 25 SETXY 35 15
     SETXY 30 0 SETXY 35 -10
     SETXY 30 -15 SETXY 25 -5
     SETXY 25 -15 SETXY 15 -15
     SETXY 5 -5 SETXY 10 -15
     SETXY 0 -15
     END

     TO WHAT2   
     SETXY -5 -5 SETXY -5 -15
     SETXY -15 -15 SETXY -10 -5
     SETXY -15 5 SETXY -20 0
     SETXY -25 -10 SETXY -30 -15
     SETXY -35 -15 SETXY -40 -10
     SETXY -40 -5 SETXY -35 -10
     SETXY -35 -10 SETXY -30 -10
     SETXY -25 0 SETXY -25 10
     END
                                  - 76 -

     TO WHAT3 
     SETXY -30 15 SETXY -30 25
     SETXY -20 35 SETXY -15 35
     SETXY -10 30 SETXY -5 25
     SETXY -5 30 SETXY 0 30
     SETXY 5 25 SETXY 5 10
     SETXY -5 5 SETXY -10 5
     SETXY -10 10 SETXY -15 5
     PU HOME PD
     END

     Type this procedure on your computer to see what it draws.  
Here's a hint...it's a circus animal.  Want to make a guess?

     __________________________________________

     Write down your guess.  You can see if you were right when 
you run the WHAT.IS.IT procedure.

     Now let's try something a bit different.

     TO WHAT1 :X
     SETXY :X + 25 25 SETXY :X + 30 20
     SETXY :X + 35 25 SETXY :X + 35 15
     SETXY :X + 30 0 SETXY :X + 35 -10
     SETXY :X + 30 -15 SETXY :X + 25 -5
     SETXY :X + 25 -15 SETXY :X + 15 -15
     SETXY :X + 5 -5 SETXY :X + 10 -15
     SETXY :X + 0 -15
     END

     TO WHAT2 :X
     SETXY :X - 5 -5 SETXY :X - 5 -15
     SETXY :X - 15 -15 SETXY :X - 10 -5
     SETXY :X - 15 5 SETXY :X - 20 0
     SETXY :X - 25 -10 SETXY :X - 30 -15
     SETXY :X - 35 -15 SETXY :X - 40 -10
     SETXY :X - 40 -5 SETXY :X - 35 -10
     SETXY :X - 35 -10 SETXY :X - 30 -10
     SETXY :X - 25 0 SETXY :X - 25 10
     END

     TO WHAT3 :X
     SETXY :X - 30 15 SETXY :X - 30 25
     SETXY :X - 20 35 SETXY :X - 15 35
     SETXY :X - 10 30 SETXY :X - 5 25
     SETXY :X - 5 30 SETXY :X + 0 30
     SETXY :X + 5 25 SETXY :X + 5 10
     SETXY :X - 5 5 SETXY :X - 10 5
     SETXY :X - 10 10 SETXY :X - 15 5
     PU HOME PD
     END

                             - 77 -

     TO WHAT.IS.IT :X
     IF :X < -140 [STOP]
     PU SETXY :X + 5 25 PD
     WHAT1 :X  WHAT2 :X  WHAT3 :X     
     MAKE "X :X - 70
     WHAT.IS.IT :X
     END

     What do you think this procedure will draw?  You deserve 
First Prize if you said a row of circus animals.

     To draw our row of animals, we use variables with the SETXY 
command.  But, wait a minute...the x-coordinate is the only 
variable...why?

     The reason for this is that the x-coordinate is the only one 
we change.  The y coordinates stay the same for each drawing.  
Remember...y-coordinates are the lines going up and down. If we 
moved them, some of the animals would be walking in mid-air.  And 
that would sure look funny!


A TARGET GAME

     Want to have some fun practicing with X and Y coordinates?  
Then type in this target game.  The turtle will draw a small 
target on the screen.  You will then be asked to guess the X and 
Y coordinates of the target.  If you guess correctly, the CHEERS 
procedure will run.  If you don't, you'll get another chance.

     Go ahead...it's fun.

     TO GAME  
     DRAW CLEARTEXT
     TARGET  ASK
     END

     TO TARGET   
     PU HT SETXY ( RANDOM 480 ) - 240 ( RANDOM 280 ) - 140
     MAKE "X XCOR + 6  MAKE "Y YCOR
     PD REPEAT 36 [FD 1 RT 10]
     PU HOME ST
     END

     TO ASK  
     PRINT [Can you hit the target?] WAIT 20
     PRINT [Give me an X- and a Y- coordinate.] WAIT 20
     PRINT [X = ] MAKE "X1 REQUEST
     PRINT [X = ] MAKE "Y1 REQUEST
     TEST OR :X1 > ABS 250 :Y1 > ABS 150
     IFTRUE PRINT [Your number is too big. Try again.] WAIT 20 ASK 
     IFFALSE PD ST SETXY :X1 :Y1

                             - 78 -

     IF OR ( :X1 > ( :X + 5 ) ) ( :X1 < ( :X - 5 ) ) PU HOME PD ASK
     IF OR ( :Y1 > ( :Y + 5 ) ) ( :Y1 < ( :Y - 5 ) ) PU HOME PD ASK
     CHEERS
     END

     TO CHEERS 
     CT REPEAT 24 [PRINT [Congratulations!]]
     WAIT 10
     PRINT [Want to play again? (Y/N) ]
     MAKE "ANS REQUEST
     IF :ANS = "Y [GAME]
     IF :ANS = "N [PRINT [Bye for now!]]
     END

     TO AND :A :B
     IF :A = "TRUE [OUTPUT :B = "TRUE]
     OUTPUT "FALSE
     END

     TO OR :A :B
     IF :A = "TRUE [OUTPUT "TRUE]
     OUTPUT :B = "TRUE
     END

     TO WAIT :T
     IF :T = 0 [STOP]
     WAIT :T - 1
     END


     Take a look at the WAIT procedure in this game.  This is 
one way to write a procedure that puts a short delay in the 
procedure.  It's a short tail-end recursion procedure that simply 
counts down to 0 from whatever variable you type in.  There's 
another WAIT procedure in the TOOLS.BUG procedure that comes with 
the LADYBUG LOGO program.  You might like using that one.

SPECIAL NOTE:  You may want to change the value of T in your 
               procedures to match the speed of your computer.
               Some computers run much slower than others.     

     There's a couple of other new things you'll find in this 
game.  

RANDOM n  This command picks a number between 0 and the number 
          you select...n.  Try it.

          PRINT RANDOM 10

          PRINT RANDOM 10



                             - 79 -

     What happened?  Bet you got numbers between 0 and 10 with a 
bunch of other numbers after a decimal point...something like 
2.8967435.  If you don't want those crazy fractions, you can tell 
the turtle to print only integers...integers are "whole" 
numbers...numbers without fractions or decimals, numbers like 1, 
2, 3, 4, 99, 1008, 7482345.

     PRINT INTEGER RANDOM 20
       
Try this one...

     REPEAT 5 [PRINT INTEGER RANDOM 20]

----------------------------------------------------------------
SPECIAL NOTE:  It's important to remember how Logo reads lines.  
               The LadyBug starts from the left, reading each 
               word, and then looking for the things that go with 
               that word.

               The first word is REPEAT.  Before the LadyBug can 
               act on that command, it needs to find the input 
               number that goes with it.  Reading to the left it 
               finds the 5.  Then LadyBug asks, REPEAT 5 what?
               REPEAT 5 looks for a list of things to do.
                
               PRINT takes one input: a word, a number, or a 
               list.  This time, PRINT finds one of LadyBug's 
               words, INTEGER.  Ok, LadyBug is going to PRINT an 
               INTEGER; but what INTEGER?  It reads to the left 
               and finds RANDOM 20.  So LadyBug prints an integer 
               between 0 and 20.  Then she goes back and repeats 
               the whole thing again until she's printed five 
               integers.

               This will help you when you're trying to 
               understand acts on your procedures.
-----------------------------------------------------------------

Let's look at the line in our game...

     SETXY ( RANDOM 480 ) - 240 ( RANDOM 280 ) - 140

Why get so complicated?  Well, remember that RANDOM only picks 
numbers between 0 and the number you select.  Since coordinates 
can be less than 0, we need random numbers that can put the 
target anywhere on the screen.

     So let's read this line...

     SETXY takes two inputs, the x and the y coordinate.  First, 
the LadyBug looks for the x coordinate.  We know the screen is 
500 turtle steps wide.  The x coordinates can be from -250 on the 

                             - 80 -

left of the screen, to 250 on the right.  But since we don't want 
our target right on the edge, we make the biggest number RANDOM 
can select a little smaller than 250.

     ( RANDOM 480 ) - 240

     If RANDOM selects the largest number...480...the LadyBug 
will subtract 240 and end up with an x coordinate of 240.  If 
RANDOM selects the smallest number it can...0...the LadyBug will 
subtract 240 and end up with an x coordinate of -240.

     Once LadyBug has her x coordinate, she reads to the right to 
find her y coordinate.

     ( RANDOM 280 ) - 140

     If we do the same arithmetic with the y coordinate as we did 
with the x coordinate, we can have a y coordinate from 140 to -
140.  So...with this line, we can have a target just about 
anywhere on the screen.

     TEST OR :X1 > ABS 250 :Y1 > ABS 150

     Here's another new command.  Reading from the left, LadyBug 
first reads the word TEST.  This is one of LadyBug's conditional 
commands.  It tests a condition to see if it is true or false.  
To find out what needs to be tested, LadyBug continues reading.

     TEST OR...  OR and AND are two procedures from the TOOLS.BUG 
that came with your LadyBug software.

     TO OR :A :B
     IF :A = "TRUE [OUTPUT "TRUE]
     OUTPUT :B = "TRUE
     END

     TO AND :A :B
     IF :A = "TRUE [OUTPUT :B = "TRUE]
     OUTPUT "FALSE
     END

Both of these procedures take two inputs...two conditions.  The 
first condition we find here is...

     :X1 > ABS 250

     :X1 is greater than what? 

     ABS stands for absolute.  This is a LadyBug primitive.  What 
it says is that it doesn't care if the x-coordinate :X1 is a 
positive number (to the right of HOME) or a negative number (to 
the left of HOME.  It drops the positive or negative and leaves 
just the number.
                             - 81 -

     TEST OR :X1 > ABS 250 :Y1 > ABS 150     

     What this line says is to test if :X1 is greater than 250 
(or less than -250) OR if :Y1 is greater than 150 (or less than -
150).

     IFTRUE PRINT [Your number is too big. Try again.] WAIT 20 ASK

     If the test is true, print "Your number is too big.  Try 
again."  If it is false, then the turtle draws a line out to the 
coordinates you guessed.

     Why not make up some of your own tests?

     TO CHECK

     TEST ____________________________________

     IFFTRUE _________________________________

     IFFALSE _________________________________

     END

     TO CHECK

     TEST ____________________________________

     IFFTRUE _________________________________

     IFFALSE _________________________________

     END


     Here's one we did...

     TO CHECK
     TEST HEADING = 0
     IFFTRUE [FORWARD 100]
     IFFALSE [HIDETURTLE]
     END


     Another way to write this test condition is to use the IF 
command...

     IF HEADING = 0 THEN FD 100 ELSE HIDETURTLE

or you can write this...

     IF HEADING = 0 [FD 100] [HIDETURTLE]

                             - 82 -

CHAPTER 7.  TALK TO YOUR COMPUTER


     One of the most interesting things about the Logo language is 
list processing.  This is the ability to use numbers, words, 
sentences, and lists of words to do all sorts of things.

     LadyBug Logo doesn't do much list processing.  But it does 
enough so that you can write some interesting games, letters, and 
things.

     TO TALK
     PRINT [HI! WHAT'S YOUR NAME?]
     PRINT SENTENCE [I DON'T THINK WE'VE MET,] REQUEST
     PRINT [HAVE YOU EVER TALKED TO A COMPUTER?]
     TEST REQUEST = 'NO
     IFTRUE PRINT [WOW! DO YOU TALK TO TURTLES, TOO?]
     IFFALSE PRINT [OH BOY!  A BEGINNER.]
     END

Here's a short and simple introduction.  Type it in and then run 
it.  What happens?  It's like a short conversation, isn't it.  
But, no, you're not really talking to the computer.

     There's really only one thing new in the TALK procedure.  Do 
you see how SENTENCE works?  SENTENCE, or SE, takes two inputs 
and prints them together.  These can be two words, two lists of 
words, or a combination of words and lists.

     PRINT SENTENCE [I DON'T THINK WE'VE MET,] REQUEST     

     I DON'T THINK WE'VE MET, is a list.  This is the first 
input.  REQUEST is the second.  This is what you typed when the 
procedure asked you for your name.

     Let's change these around a bit so we can see what the 
SENTENCE command can do.

     TO TALK
     PRINT [HI! WHAT'S YOUR NAME?]
     MAKE "ANS REQUEST
     MAKE "NAME WORD :ANS ",
     MAKES "REPLY SE :NAME [ MY NAME IS LADYBUG.] 
     PRINT SENTENCE [I DON'T THINK WE'VE MET,] :REPLY
     PRINT [HAVE YOU EVER TALKED TO A COMPUTER?]
     TEST REQUEST = 'NO
     IFTRUE PRINT [WOW! DO YOU TALK TO TURTLES, TOO?]
     IFFALSE PRINT [OH BOY!  A BEGINNER.]
     END

Hey...there's another command in there now...WORD.  Do you see 
the difference between SENTENCE and WORD?

                             - 83 -

NUMBERS, WORDS, LISTS, AND SENTENCES


     Look closely.  SENTENCE can combine words and lists.  WORD 
can only combine characters and other words.  SENTENCE produces a 
list.  WORD produces another word.  To see the difference, try 
something like this...

     PRINT WORD "A "B
     PRINT SENTENCE "A "B

or this...

     PRINT WORD 1 2
     PRINT SE 1 2

Hmmmm...this is getting interesting.  What would happen if we did 
this...

     MAKE "A WORD 1 2
     MAKE "B WORD 3 4
     PRINT :A + :B

You get an error message...

     ==> Invalid symbol '+
     
Try this... 

     PRINT WORD :A :B

     What happened?  Bet you got 1234, right?  So let's do some 
testing to see what we've got here.

     PRINT :A 
     IF NUMBER? :A [PRINT "TRUE]

     A new primitive!  And with a question mark.  Hmmmm?  This 
tells the Ladybug that IF :A is a number, print TRUE.  Since 
nothing happened, I guess we can say that :A is a word and not a 
number.  Another way to say this...with another new primitive...

     PRINT :A
     IF NOT NUMBER? :A [PRINT "FALSE]

     This time, the LadyBug prints FALSE.  IF :A is NOT a number, 
print FALSE.

     In this situation, the LadyBug sees the numbers as words and 
not as numbers.  Seems weird, doesn't it.



                             - 84 -

     Has your family ever been on a vacation and sent lots of 
postcards to friends back home?  Those cards all seem the same, 
don't they...

     Dear ______,

     Here we are in wonderful ______.  We're having a great time 
     ________ and _______.  The weather is very _______. We'll be 
     home _________.  See you then.
                         
     Love,

     _________

Wouldn't it be nice to have a procedure to print your cards for 
you.

     TO SETUP
     PRINT [WHO IS THIS CARD FOR?]
     MAKE "FRIEND REQUEST
     PRINT [WHERE ARE YOU WRITING FROM?]
     MAKE "VAC REQUEST
     MAKE "VAC WORD :VAC ".
     PRINT [WHAT ARE YOU DOING?]
     MAKE "ACT1 REQUEST
     PRINT [WHAT ELSE?
     MAKE "ACT2 REQUEST
     MAKE "ACT2 WORD :ACT2 ".
     PRINT [HOW'S THE WEATHER?]
     MAKE "WEA REQUEST
     MAKE "WEA WORD :WEA ".
     PRINT [WHEN WILL YOU BE HOME?]
     MAKE "ARR REQUEST
     MAKE "ARR WORD :ARR ".
     PRINT [HOW WILL YOU SIGN THE CARD?
     MAKE "SIG REQUEST
     END


Now we'll take this information and print it on the postcards.

     TO POSTCARD
     PRINT SE [DEAR] :FRIEND
     PRINT "
     TYPE SE [HERE WE ARE IN WONDERFUL] :VAC PRINT [WE'RE HAVING]
     TYPE SE [A GREAT TIME] :ACT1 TYPE SE "AND :ACT2 PRINT "THE
     TYPE SE [WEATHER IS] :WEA PRINT SE [WE'LL BE HOME] :ARR
     PRINT [SEE YOU THEN.]
     PRINT "
     PRINT [LOVE,]
     PRINT "
     PRINT :SIG
     END
                             - 85 -
   
     LadyBug Logo cannot process words and lists the way that the 
Logo language can.  After all, LadyBug Logo is actually written 
in BASIC.  But one of the fun things you can do is trick the 
LadyBug into thinking she can do list processing.

     Look at any book on Logo and usually you'll find a procedure 
that picks parts of speech and combines these into sentences; 
something like this...

     TO HEADLINES
     MAKELISTS
     PRINTHEADLINES
     END

     TO MAKELISTS
     MAKE "ADJ [HAPPY GLAD ANXIOUS GOOD SINCERE]
     MAKE "NOUN [SANTA CHILDREN PEOPLE FRIENDS PARENTS]
     MAKE "VERB [GAVE RECEIVED SPREAD SHARED WISHED]
     MAKE "OBJ [GIFTS LOVE CHEER GLADNESS JOY HAPPINESS]
     END
     
     TO PRINTHEADLINES
     PR (SE PICK :ADJ PICK :NOUN PICK :VERB PICK :OBJ)
     WAIT 10
     PRINTHEADLINES
     END

     TO PICK :WORDS
     OUTPUT ITEM (1 + RANDOM (COUNT :WORDS)) :WORDS
     END

     When you enter HEADLINES, the first thing that Logo does is 
make up lists of words: ADJ, NOUN, VERB, and OBJ.  Then the next 
procedure is called.  PRINTHEADLINES tells the computer to PRint 
a SEntence...but what sentence?

     What do you think the PICK procedure does?

     Remember...to understand any Logo line, you start at the left 
and move to the right, one command at a time.  OUTPUT takes one 
input.  That input is ITEM.  

     Well, ITEM takes two inputs: a number and something 
else...like the 4th list, the 2nd word.  The next thing you see 
after ITEM is in parenthesis.  That means that... 

     (1 + RANDOM (COUNT :WORDS))

is all one element.  But what about all those parenthesis?




                             - 86 -

     The easiest way to read those is to start with the 
parenthesis on the inside...

     COUNT :WORDS

     So...if I start with PICK :ADJ, then this line becomes...

     COUNT :ADJ

     How many words are inside the brackets in the MAKELISTS 
procedure?  There are five adjectives, right?  So...if we COUNT 
the ADJectives, we have 5.  Now we move to the next set of 
parenthesis.  Now we have...

     (1 + RANDOM 5)

     RANDOM 5 by itself would give us the five numbers 0, 1, 2, 
3, and 4.  Since we don't want Logo to use the '0, we tell it to 
add 1 to RANDOM 5.  In this way, we're working with five whole 
numbers, 1, 2, 3, 4, and 5.  So now we have...

     OUTPUT ITEM (1 + RANDOM (COUNT :WORDS)) :WORDS 

or

     OUTPUT the 1st word in the ADJ list...or the 2nd, 3rd, 4th 
or 5th.
     
     Now this line begins to make a bit more sense...

     PR (SE PICK :ADJ PICK :NOUN PICK :VERB PICK :OBJ)

     Logo is going to print a random ADJ, a random NOUN, a random 
VERB, and a random :OBJ.  You'll get sentences like this...

     HAPPY SANTA GAVE CHEER
     GLAD CHILDREN RECEIVED GIFTS
     GOOD PEOPLE SHARED JOY
     ANXIOUS CHILDREN WISHED JOY
     HAPPY PARENTS SPREAD LOVE

     How can LadyBug Logo handle this?  

     Since the LadyBug doesn't know how to use lists in the same 
way that other types of Logo can, she changes things into 
numbers.          

     TO HEADLINES   
     TYPE SE ADJ NOUN PRINT SE VERB OBJ
     WAIT 10 HEADLINES
     END


                             - 87 -

     This procedures tells the LadyBug to TYPE a SEntence using 
the output of ADJ and NOUN.  Then, on the same line, PRINT a 
SEntence using VERB and OBJ.

     In the parts of speech procedures, the LadyBug does things a 
bit differently.  She's real good at numbers...not so good 
computing with words and lists.  So...once she gets her random 
number (she doesn't care if it's a zero), she changes that number 
to a word.

     TO ADJ   
     LOCAL "ANS
     MAKE "ANS INTEGER RANDOM 10
     IF :ANS = 0 [MAKE "ADJ "HAPPY]
     IF :ANS = 1 [MAKE "ADJ "GLAD]
     IF :ANS = 2 [MAKE "ADJ "ANXIOUS]
     IF :ANS = 3 [MAKE "ADJ "GOOD]
     IF :ANS = 4 [MAKE "ADJ "GLAD]
     IF :ANS = 5 [MAKE "ADJ "BEAUTIFUL]
     IF :ANS = 6 [MAKE "ADJ "GREAT]
     IF :ANS = 7 [MAKE "ADJ "SAD]
     IF :ANS = 8 [MAKE "ADJ "TENDER]
     IF :ANS = 9 [MAKE "ADJ "FUNNY]
     OUTPUT :ADJ
     END

In the ADJ procedure, the LadyBug changes the local variable, 
ANS, into an adjective. Here, she uses quotes to mark her ADJ 
words.  But she does things differently in the NOUN procedure.  
Why?

     TO NOUN   
     LOCAL "ANS
     MAKE "ANS INTEGER RANDOM 6
     IF :ANS = 0 [MAKE "NOUN [SANTA ]]
     IF :ANS = 1 [MAKE "NOUN [PARENTS ]]
     IF :ANS = 2 [MAKE "NOUN [PEOPLE ]]
     IF :ANS = 3 [MAKE "NOUN [CHILDREN ]]
     IF :ANS = 4 [MAKE "NOUN [FRIENDS ]]
     IF :ANS = 5 [MAKE "NOUN [NEIGHBORS ]]
     OUTPUT :NOUN
     END  

     LadyBug wants to print her headlines correctly.  The 
SEntence command will leave a space between the ADJective and the 
NOUN, but she won't leave a space after the noun unless we tell 
her how to do that. 

     Here we use a list.  You might think that's just one word 
inside the brackets, but the LadyBug sees that as a word and a 
space. That's a little different.


                             - 88 -

     TO VERB   
     LOCAL "ANS
     MAKE "ANS INTEGER RANDOM 5
     IF :ANS = 0 [MAKE "VERB "GAVE]
     IF :ANS = 1 [MAKE "VERB "RECEIVED]
     IF :ANS = 2 [MAKE "VERB "SPREAD]
     IF :ANS = 3 [MAKE "VERB "SHARED]
     IF :ANS = 4 [MAKE "VERB "WISHED]
     OUTPUT :VERB
     END

     In the OBJect procedure, we've asked the LadyBug to do 
something else different.  Sentences should have periods, right?
OK, maybe newspaper headlines don't always have periods in them. 
These headlines do so you can see another way to use the WORD 
command.  Here the LadyBug combines the word with the quotes with 
the period.

     TO OBJ   
     LOCAL "ANS
     MAKE "ANS INTEGER RANDOM 6
     IF :ANS = 0 [MAKE "OBJ WORD "GIFTS ".]
     IF :ANS = 1 [MAKE "OBJ WORD "LOVE ".]
     IF :ANS = 2 [MAKE "OBJ WORD "CHEER ".]
     IF :ANS = 3 [MAKE "OBJ WORD "JOY ".]
     IF :ANS = 4 [MAKE "OBJ WORD "PEACE ".]
     IF :ANS = 5 [MAKE "OBJ WORD "GLADNESS ".]
     IF :ANS = 6 [MAKE "OBJ WORD "TIDINGS ".]
     IF :ANS = 7 [MAKE "OBJ WORD "HAPPINESS ".]
     OUTPUT :OBJ
     END

The WAIT procedure gives us time to read the headline before the 
next one appears.
  
     TO WAIT :T
     IF :T = 0 [STOP]
     WAIT :T - 1
     END

Now the LadyBug can print sentences just like the other types of 
Logo. Only the LadyBug's headlines have periods.

     HAPPY SANTA GAVE CHEER.


     Before we finish with HEADLINES, let's take another look.  

     Four words like these aren't really very exciting.  Can we 
dress up our HEADLINES a bit more?



                             - 89 -

     TO HEADLINES   
     TYPE SE ADJ NOUN PRINT SE VERB OBJ
     WAIT 10 HEADLINES
     END

What if we changed that second line...

     TYPE SE ADJ NOUN TYPE VERB PRINT SE ADJ OBJ

That's OK...except we have the verb and the second adjective 
running together.  Oh, well...what do you think?  Is there a way 
to fix that?

     What would you do?

     Logo postcards and headlines may seem a bit silly.  But what 
about a word game...like the game of Nim.

     TO NIM
     CT
     REPEAT 5 [PR "]
     PR [Welcome to the Game of NIM!]
     PR "
     PR [This is a game where you and the]
     PR [computer take turns picking stones]
     PR [from a pile.  The challenge is not]
     PR [to get stuck with the last stone.]
     PR "
     PR [You decide. How many stones will]
     PR [each player pick on each turn?]
     MAKE "PICK REQUEST MAKE "PICKS :PICK + 1
     PR [How many turns will we have to pick?]
     MAKE "TURNS REQUEST
     MAKE "TOTAL :PICKS * :TURNS + 1
     GAME OVER
     END

     TO GAME   
     TYPE [There are ] TYPE :TOTAL PR [ stones in a pile.]
     TYPE [Take from 1 to ] TYPE PICK PR [ stones.]
     MAKE "KEY REQUEST
     IF OR :KEY > :PICK :KEY < 1 [CORRECT]
     TYPE [I take ] PR :PICKS - :KEY
     MAKE "TOTAL :TOTAL - :PICKS
     IF :TOTAL = 1 [STOP]     IF :TOTAL > 1 [GAME]
     END


     TO CORRECT   
     PR [Try again!]
     MAKE "KEY REQUEST
     END

                             - 90 -

     TO OVER  
     REPEAT 3 [PR "]
     PR [There is one stone left. I win again.]
     END

     TO PR :LIST
     PR :LIST
     END

     TO OR :A :B
     IF :A = "TRUE [OUTPUT "TRUE]
     OUTPUT :B = "TRUE
     END

     Why does the LadyBug always win?  Can you figure out how the 
she does it?  If you go through the game step-by-step you'll find 
it isn't very hard.  Then you can zap your friends when you play 
the game off the computer!!!!

LADYBUG MYSTERY

     NIM is a nice puzzle game.  But how about a real mystery? 
MYSTERY will really challenge your detective skills.  Ladybug 
describes a crime to you and shows you the list of suspects.  
It's your job to figure out who committed the crime.  The answer 
is right there under your nose...but not very easy to find.     
Can you figure it out? 

     TO START  
     CLEARTEXT SPACE 5  SPACE 5
     PR [Thomas Magnum was killed at]
     PR "
     CHECK
     PRINT SE [the following time: ] WORD :T [ o'clock.]
     WAIT 10
     MYSTERY
     END

     TO MYSTERY  
     CT SPACE 5 PR [The list of suspects:]
     SPACE 2
     PR [John]
     PR [Harry]
     PR [Martha]
     PR [Clyde]
     PR [George]
     SPACE 1
     PR [Press "s" if you think you have the crime solved.]
     PR [Press "q" to question the suspects.]
     MAKE "COM RQ
     IF :COM = "s [CRIMESOLVED]
     IF :COM = "q [QUESTION]
     END
                             - 91 -

     TO QUESTION  
     CT SPACE 3
     PR [Who do you want to question?]
     MAKE "COM RQ
     IF :COM = "j [John]
     IF :COM = "g [George]
     IF :COM = "m [Martha]
     IF :COM = "c [Clyde]
     IF :COM = "h [Harry]
     END

     TO CHECK  
     MAKE "T ( 1 + INTEGER RANDOM 6 )
     IF :T = 0 [MAKE "T 12]
     END

     TO CRIMESOLVED  
     CLEARTEXT
     SPACE 5
     PR [0 = Martha]
     PR [1 = George]
     PR [2 = Clyde]
     PR [3 = Harry]
     PR [4 = John]
     PR [Well, smart guy, who dunnit?]
     MAKE "COM RQ
     IF :COM = :T [SOLVED STOP]
     STUPID
     END

     TO SOLVED  
     CLEARTEXT
     SPACE 5
     PR [You solved the crime!]
     PR [Congratulations. You advance to the Pros!]
     SPACE 2
     PR [Want to solve another crime?]
     IF RQ = "Y [START] [TOPLEVEL STOP]
     END

     TO STUPID  
     CLEARTEXT
     SPACE 5
     PR [You are a lousy Private Eye!]
     IF :T = 0 [PR [Martha dunnit!] TOPLEVEL ]
     IF :T = 1 [PR [George dunnit!] TOPLEVEL ]
     IF :T = 2 [PR [Clyde dunnit!] TOPLEVEL ]
     IF :T = 3 [PR [Harry dunnit!] TOPLEVEL ]
     IF :T = 4 [PR [John dunnit!] TOPLEVEL ]
     END



                             - 92 -

     TO GEORGE  
     CLEARTEXT
     SPACE 5
     PR [12:00 In bedroom sleeping..]
     PR [1:00 ?]
     PR [1:30 Eating in kitchen.]
     PR [2:30 Helping Martha clean.]
     PR [3:00 Playing games in the arcade.]
     PR [6:00 Thomas was dead, everybody left.]
     PR [Press any key:]
     IGNORE RC
     MYSTERY
     END

     TO CLYDE  
     CLEARTEXT
     SPACE 5
     PR [12:00 In the lounge.]
     PR [1:00 Eating in kitchen.]
     PR [2:00 ?]
     PR [2:30 Playing games in the arcade.]
     PR [6:00 Thomas was dead, everybody left.]
     PR [Press any key:]
     IGNORE RC
     MYSTERY
     END

     TO MARTHA  
     CLEARTEXT
     SPACE 5
     PR [12:00 ?]
     PR [12:30 Preparing lunch.]
     PR [1:00 in kitchen eating.]
     PR [2:00 cleaning up.]
     PR [3:00 resting in bedroom.]
     PR [5:00 in the TV room.]
     PR [6:00 Thomas was dead, everybody left.]
     PR [Press any key:]
     IGNORE RC
     MYSTERY
     END

     TO HARRY  
     CLEARTEXT SPACE 5
     PR [12:00 in lounge with John.]
     PR [1:00 in the kitchen eating.]
     PR [2:00 watching TV.]
     PR [3:00 ?]
     PR [3:30 in the arcade.]
     PR [6:00 Thomas was dead, everybody left.]
     PR [Press any key:]
     IGNORE RC
     MYSTERY
     END                             - 84 -

     TO JOHN  
     CLEARTEXT SPACE 5
     PR [12:00 in lounge.]
     PR [1:00 in kitchen eating.]
     PR [2:30 playing cards in the den.]
     PR [4:00 blinking mad at my losses.]
     PR [5:00 ?]
     PR [6:00 Thomas was dead, everybody left.]
     PR [Press any key:]
     IGNORE RC
     MYSTERY
     END

     TO PR  :LIST
     PRINT :LIST
     END

     TO SPACE  :SIZE
     REPEAT :SIZE [PR []]
     END

     TO WAIT  :TIME
     IF :TIME = 0 STOP
     MAKE "TIME :TIME - 1
     WAIT :TIME
     END

     TO IGNORE  :KEY
     END


What's Next?

     By now, you should have a pretty good idea of what LadyBug 
Logo is all about.  And, in case you're wondering, there's lots 
more to do, many more things to discover.  Some of these are
described in the last chapter.

     Take a look...














                             - 94 -

CHAPTER 8. A FEW PARTING WORDS



     You might think that this is the end.  Well...not quite.  
Along the way, we've told you about some other projects you can 
explore.  But rather than fill up the book with extra stuff, we 
put these ideas here.  We hope this shows you that there are 
many, many other things you can do with LadyBug Logo...many ideas 
to explore, many new things to discover.

ADDING SOME COLOR

     Drawing with a white pen on a black screen all of the time 
can get very boring.  If you've got a color monitor, why not add 
some color to your drawings.  You can change the color of the 
background and the color of the turtle's pen.

BACKGROUND  or BG  or SETBG

     The Background command changes the color of the background 
but does not change the pen color.
     0    Black               8    Gray
     1    Blue                9    Light Blue
     2    Green               10   Light Green
     3    Cyan (a light blue) 11   Light Cyan  
     4    Red                 12   Light Red
     5    Magenta (Violet)    13   Light Magenta
     6    Brown               14   Yellow
     7    White               15   Bright White          

PENCOLOR  or PC  or SETPC

     LadyBug Logo gives the turtle two palettes of color for her 
pen.  Each palette has four colors...three you can see.

Color          Palette 0           Palette 1

  0            Background          Background
  1            Green               Cyan
  2            Red                 Magenta
  3            Brown               White

     PC 0 sets the pen color to the same color as the background.  
It's a great way to erase lines.

     Another thing to remember is that the turtle always uses 
Palette 1 until you tell her to change to Palette 0.  





                             - 95 -
  
     If you want to see lots of different pen colors and 
background colors, take a look at this procedure...

     TO COLOR :BKG :PEN :PAL
     BG :BKG PC :PEN PALETTE :PAL
     PRINT "
     TYPE SE [BG =] :BKG TYPE SE [ PEN =] :PEN TYPE SE [ PAL =] :PAL wait 2
     FD 100 RT 90 WAIT 3
     MAKE "BKG :BKG + 1
     IF :BKG > 15 MAKE "BKG 0
     MAKE "PEN :PEN + 1
     IF :PEN > 3 MAKE "PAL :PAL + 1
     IF :PEN > 3 MAKE "PEN 0
     IF :PAL > 1 MAKE "PAL 0
     COLOR :BKG :PEN :PAL
     END

     Use the WAIT procedure from the LadyBug's tool procedure 
(TOOLS.BUG) or use this WAIT procedure.

     TO WAIT :T
     IF :T = 0 [STOP]
     WAIT :T - 1
     END

     Play around with colors...and then try adding color to your 
procedures.  When you do, there's another primitive you'll find 
helpful.  This one is PAINT.

     PAINT lets you fill a shape with color.  It takes two 
inputs: the color you want to use to fill your shape, and the 
bordercolor.  The bordercolor is the pencolor at the edge of your 
shape.  

     Let's say you've been drawing a picture using PC 3...that's 
white.  Now you want to fill in your shape with blue.

     PAINT 1 3

     There you go...a shape draw in white and filled with blue.













                             - 96 -

THE LOGO ROBOT

     This little game can be a lot of fun for young people just 
getting started with LadyBug Logo.  It helps them learn their 
directions.

     To start the robot, type Start.  Type F to make the robot go 
faster, S to make the robot slow down.  In the MOVE procedure, 
you'll see two conditional statements that send the robot off in 
another direction when it gets too close to the edge of the 
screen.

     TO START  
     SETH 30
     MAKE "SPEED 0
     MOVE
     END

     TO MOVE 
     FORWARD :SPEED
     IF ABS XCOR > 220 THEN RIGHT 150
     IF ABS YCOR > 120 THEN RIGHT 150
     YES.MASTER
     MOVE
     END

     TO YES.MASTER  
     MAKE "C READKEY
     IF :C = "R THEN RIGHT 30
     IF :C = "L THEN LEFT 30
     IF :C = "U THEN PENUP
     IF :C = "D THEN PENDOWN
     IF :C = "Q THEN QUIT
     IF :C = "F THEN MAKE "SPEED :SPEED + 2
     IF :C = "S THEN MAKE "SPEED :SPEED - 2
     END

     TO READKEY  
     IF KEYP THEN OUTPUT READCHAR
     OUTPUT "FALSE
     END

     TO QUIT  
     TOPLEVEL
     END








                             - 97 -

FROM TWO TO THREE DIMENSIONS

     
     Here's a challenge for you...put the soccer ball pattern on 
the screen.

     The first thing you see, looking at a soccer ball, is a 
bunch of hexagon shapes.  When we asked some young computer club 
people to draw this pattern on the screen, they thought it was 
easy...

     TO SOCCER.BALL :DIS
     REPEAT 6 [REPEAT 6 [FD :DIS RT 60] FD :DIS LT 60]
     END

     The boys thought that all they had to do is draw a series of 
hexagons.  Try their SOCCER.BALL procedure.  It's not quite 
right, is it?

     The girl's team were the first to figure out that they could 
not make the soccer pattern on the screen as it appears on the 
ball.  They had to flatten it out.  At first, they thought this 
procedure was wrong.  But it was really correct.
       
     TO SOCCER :DIS
     REPEAT 5 [REPEAT 6 [FD :DIS RT 60] FD :DIS LT 72]
     END

     The girls printed twelve of their patterns, colored them, 
and made their own soccer ball.  When they were finished, the 
decided it made a better pinata.  So they filled it with candy 
and had a party.

FOLDING PAPER FUN


     Making the soccer ball out of paper is just one of many 
things you can do with the LadyBug and paper.  You can do all 
sorts of things with three dimensional objects.  

     How about a simple cube?  This takes you from the two 
dimensional square to a three dimensional cube.

     TO CUBE  :D :X1 :Y1
     PU SETXY :X1 :Y1 SETH 0 PD
     REPEAT 4 [SQUARE :D SETX :X1 + :D MAKE "X1 XCOR]
     MAKE "X1 XCOR - ( :D * 3 )
     MAKE "Y1 YCOR - :D
     PU SETXY :X1 :Y1 PD
     REPEAT 3 [SQUARE :D FD :D]
     HT
     END

                             - 98 -

     TO CUBES  :D :X1 :Y1
     CUBE :D :X1 :Y1
     CUBE :D :X1 + ( :D * 4 ) :Y1
     END

     TO SQUARE  :D
     REPEAT 4 [FD :D RT 90]
     END

          
     What about three dimensional shapes using triangles?


     TO MOVEl  :D
     LT 60 FD :D RT 60
     END

     TO TETRAHEDRON  :D
     RT 30 TRI :D MOVER :D TRI :D
     MOVEL :D TRI :D
     END

     TO MOVER  :D
     RT 60 FD :D LT 60
     END

     TO TRIS  :D
     PU SETX - 120 PD
     RT 30
     REPEAT 6 [TRI :D MOVER :D]
     END

     TO TRIR  :D
     RT 60 FD :D TRI :D
     END

     TO TRI  :D
     REPEAT 3 [FD :D RT 120]
     END

     TO OCTAHEDRON  :D
     LT 30 TRI :D RT 30 TETRAHEDRON :D
     LT 60 TRI :D TRIR :D TRIF :D
     END

     TO TRIF  :D
     FD :D RT 60 TRI :D
     END





                             - 99 -

WHAT'S NEXT
     
     Seems we just got started and here we are.  And there are so 
many other things to do.  We haven't even talked about music.  
And what about all the other games and projects?  Well...there 
has to be something few left for you to explore on your own.

     There are many procedures on CompuServe's Logo Forum that 
you can download and use.  Some may need a few changes.  But 
you're pretty good at this by now.

     If you have any questions about LadyBug Logo, don't forget 
the LadyBug Help screens.  And don't forget the LadyBug book that 
came with the software.  Most importantly, don't forget the Logo language.  If you like LadyBug Logo, you'll love Logo and LogoWriter.  You'll find more information on these products in the Logo Library.


TWO FINAL WORDS...

     A very smart person once said that "imagination is more 
powerful than knowledge."  He was Albert Einstein.  For one 
thing, knowledge is things we already know.  Imagination is that 
part of humans that lets us think up new knowledge.

     Another smart person once said that "a person who has 
imagination without learning, has wings but no feet."  LadyBug 
Logo and the computer are fantastic learning tools where you 
can plant your feet so your mind can soar with the eagles.

     Go ahead...try it!


















                             - 88 -

THE LOGO LIBRARY

Here's a list of Logo books primarily for home use.  There are
many other classroom activity books available that can be found
in catalogs and other bibliographies.  This list comes from Logo
Forum members and other "satisfied customers."
For a complete list of available books on Logo, see BOOKS IN
PRINT in the reference section of your library or here on
CompuServe (GO REFERENCE).

Abelson, Hal:  Logo for the Apple II, 1982, McGraw-Hill.
               ISBN 0-07-000426-9
               Apple Logo for the Apple II, 1982, McGraw-Hill
               ISBN 0-07-0004250-0
Avery, Rachel: Logo & the IBM PC, 1985, Prentice-Hall,
               ISBN 0-13-064116-0
Bearden, Donna A Bit of Logo Magic. 1984 Prentice-Hall
               ISBN 0-8359-0495-0
Billstein, Rick, et al: MIT Logo for the Apple: A Problem Solving
               Approach, 1985, Benjamin-Cummings.
               ISBN 0-8053-0866-1
               Apple Logo: Programming and Problem Solving, 1986
               ISBN 0-8053-0866-0
Ihor Charischak, Creating Dynamic Stories with LogoWriter,
               Classroom Press 10 Bogert Avenue, White Plains, NY
               10606
Feurzeig, Wallace, et al. The Logo Language: Learning Mathematics
               Through Programming, 1977, Entelek
               ISBN 0-87567-105-0
               Exploring Language with Logo, 1987, MIT Press
               ISBN 0-262-57065-3
Friendly, Michael. Advanced Logo, A Language for Learning. 1988                                  Lawrence Erlbaum Associates, 366 Broadway,
               Hillsdale, NJ 07642
               Paper back: ISBN 0-8058-0074-3, $24.95
               Hard back: ISBN 0-89859-933-3, $69.95
               Procedure Disks:
               LCSI/Apple Logo II  ISBN 0-8058-0043-3  $29.95
               IBM Logo            ISBN 0-8058-0044-1  $29.95
               Macintosh Logo      ISBN 0-8058-0430-7  $29.95
Harvey, Brian  Computer Science Logo Style, Volumes 1, 2, and 3
               1985 - 1987, MIT Press
               Vol 1. ISBN 0-262-58072-1
               Vol 2. ISBN 0-262-58080-2
               Vol 3. ISBN 0-262-58086-1
Martin, Kathleen, et al.  Primarily Logo  Prentice-Hall, 1984
               ISBN 0-8359-5677-6
McGriff, Duane, et al. A Beginner's Guide to List Processing: The
               Other Side of Logo, 1986, Prentice-Hall
               ISBN 0-13-071705-3
Thornburg, David  Discovering Apple Logo; An Introduction to Art
               & Patterns in Nature. Addison-Wesley
               ISBN 0-201-07769-8
                             - 101 -

Tipps, Steve, et al.  Nudges: IBM Logo Projects for Children
               HR&W, 1984  ISBN 0-03-000224-9
Watt, Daniel   Learning With Logo, 1984  McGraw-Hill
               ISBN 0-8359-1200-0
               (There have been several versions of this book,
                not all of which remain in print.)


WHERE TO FIND LOGO?
-------------------

Logo for the IBM PC:

LADYBUG LOGO is a freeware package that can be downloaded from 
Library 11 on the Logo Forum and from other bulletin boards..  
This is a limited package with turtle graphics, math, and a few 
list processing features.  The Library includes "The LadyBug's 
Discovery Book," a family idea book for all ages, and a variety 
of procedures to exemplify what the package can do.

IBM LOGO is a full featured version of the Logo language 
available through IBM dealers.  Also available by mail from 
Advanced Computer Products, Santa Ana, CA. 1-800 FONE ACP.

LOGOWRITER is another full-featured package designed primarily 
for school use.  A home version is available through IBM dealers 
or direct from Logo Computer Systems Inc. 1-800 321-LOGO.


























                             - 102 -

APPENDIX B. Ladybug Logo Commands


    Command             Input  
    -------             -----
    ABS                 value
    ARCTAN              angle
    Arithmetic:         +  -  *  /  \  ^
    BacK                turtle steps (distance
    BackGround
    BackGround          color (0 - 15)
    CATalog
    CLEARINPUT
    ClearScreen
    ClearText
    CLEARWS
    CLIP  NOCLIP
    COntinue
    COS                 angle
    CURSOR              column row
    DEFINE              name [list]
    DRAW  NODRAW
    EDit                procedure name
    EDit ALL
    END
    ERASE               procedure name
    ERASE ALL
    ERASEFILE           filename
    ERNAME              variablename
    ERNAME ALL
    ERROR message
    EXP                 power
    ForwarD             turtle steps (distance
    goodBYE
    HEADING
    HIDDEN?
    HideBug
    HideTurtle
    HOME
    IF condition        THEN action
    IF condition        THEN action1 ELSE action2
    IF condition        [action1] [action2]
    IF condition        [action]
    IFFALSE             action
    IFTRUE              action
    INTEGER             number
    KEYP
    LefT                turtle turns (degrees)
    LOAD                filename
    LOCAL               variablename
    LOG                 number
    MAKE                variablename value
    NOTRACE
                             - 103 -

    NUMBER?             word
    OUTPUT              value
    PADDLE              number
    PADDLEBUTTON        n
    PAINT               paint  border
    PALETTE             0 or 1
    PAUSE
    PenColor            color (0, 1, 2, or 3)
    PenDown
    PENDOWN?
    PenUp
    PENUP?
    PRINT               "word or [list]
    PRINT1              "word or [list]
    PrintOut            procedurename
    PrintOut            variablename
    RANDOM              range
    RANDOMIZE           number
    RC?
    READ                filename
    ReadChar
    READCHARACTER
    Relational:         <  <=  >  >=  <>  =  NOT
    REPEAT              number [list]
    ReQuest
    RighT               turtle turns (degrees)
    RUN                 list
    SAVE                filename
    SCRUNCH
    SEntence            "word "word
    SEntence            "word [list]
    SEntence            [list] [list]
    SETBG               color (0 - 15)
    SETHeading          degrees
    SETPAL              palette (0 or 1)
    SETPC               color (0, 1, 2, or 3)
    SETSCRUNCH          number
    SETWIDTH            columns
    SETX                x coordinate
    SETXY               x and y coordinates
    SETY                y coordinate
    ShowBug
    SHOWING?
    ShowTurtle
    SIGN                number
    SIN                 angle
    SQRT                number
    STICK               number
    STICKBUTTON         number
    STOP
    TAN                 angle
    TEST                condition

                             - 104 -

    TextCOLumnS         columns
    THING               word
    TO                  procedurename inputs
    TOPLEVEL
    TOPLEVEL
    TRACE
    TYPE                "word or [list]
    WINDOW  NOWINDOW
    WRAP
    XCOR
    YCOR










































                             - 105 -

APPENDIX C. The LadyBug's Tool Box

     These procedures are in the TOOLS.BUG procedure.  A number 
of new procedures have been added to make it easier to translate 
other Logo procedures to LadyBug Logo.

Logical Tools
-------------

     to "and    :a :b
     if :a = "true [output :b = "true]
     output "false
     end

     to "or    :a :b
     if :a = "true [output "true]
     output :b = "true
     end

     to "while    :condition :list
     if ( run :condition ) = "false then stop
     run :list
     while :condition :list
     end

     to "forever    :list
     repeat 32000 :list
     forever :list
     end

     to "xor    :a :b
     if :a = "true [output :b = "false]
     output :b = "true
     end

Math Tools
----------

     to "max   :a :b
     if :a > :b [output :a]
     output :b
     end

     to "min   :a :b
     if :a > :b [output :b]
     output :a
     end

     to "remainder   :a :b
     make "c :a / :b
     make "d ( :c - integer :c ) * :b
     output :d
     end
                             - 106 -

     to "sum :a :b
     op :a + :b
     end

     to "product :a :b
     op :a * :B
     end

     to "quotient :a :b
     op :a / :b
     end

     to "sq :n
     op :n * :n
     end
    
     to "cube :n
     op :n * :n * :n
     end

Circle, Arc, and Area Tools
---------------------------
     to "arc.r :x :y :radius :angle
     local "amt make "amt :radius * :pi / 180
     pu setxy :x :y pd
     fd :radius rt 90
     repeat :angle [fd :amt rt 1]
     end

     to "arc.l :x :y :radius :angle
     local "amt make "amt :radius * :pi / 180
     pu setxy :x :y pd
     fd :radius lt 90
     repeat :angle [fd :amt lt 1]
     end

     to "circle  :x :y :radius
     local "amt make "p heading
     make "amt :radius * :pi / 180
     pu setxy :x :y setx xcor - :radius seth 0
     repeat 360 [fd :amt rt 1]
     pu setxy :x :y  seth :p
     end

     to "arcl  :radius :degrees
     local "step local "rem
     make "step 2 * :radius * 3.14159 / 36
     make "rem remainder :degrees 10
     repeat :degrees / 10 [lt 5 fd :step lt 5]
     if :d > 0 [fd :step * :d / 10 lt :d]
     end
                             -107 -


     to "arcr  :radius :degrees
     local "step local "rem
     make "step 2 * :radius * 3.1416 / 36
     make "rem remainder :degrees 10
     repeat :degrees / 10 [rt 5 fd :step rt 5]
     if :d > 0 [fd :step * :d / 10 rt :d]
     end

     to "circlel  :radius
     local "step
     make "step 2 * :radius * 3.1416 / 36
     repeat 36 [lt 5 fd :step lt 5]
     end

     to "circler  :radius
     local "step
     make "step 2 * :radius * 3.1416 / 36
     repeat 36 [rt 5 fd :step rt 5]
     end

     to "filledcir  :x :radius
     local "x1 local "y1 local "p
     make "x1 xcor
     make "y1 ycor
     make "p heading
     repeat 360 [fd :radius pu setx :x rt 1 seth :p]
     pu setxy :x1 :y1 seth :p pd
     end

     to "filledpie  :x :y :radius :angle
     local "x1 local "y1 local "p
     make "x1 xcor
     make "y1 ycor
     make "p heading
     pu setxy :x :y seth :p pd
     repeat :angle [fd :radius pu setxy :x :y rt 1 pd]
     pu setxy :x1 :y1 seth :p pd
     end

     to "pie  :x :y :radius :angle
     local "x1 local "y1 local "p local "amt
     make "x1 xcor
     make "y1 ycor
     make "pi 3.14159
     make "p heading
     make "amt :radius * :pi / 180
     pu setxy :x :y seth :p
     fd :radius rt 90
     repeat :angle [fd :amt rt 1]
     rt 90 fd :radius rt 180
     pu setxy :x1 :y1 seth :p pd
     end

                             - 108 -

     to "arc.r  :x :y :radius :angle
     local "x1 local "y1 local "p local "amt
     make "p heading
     make "x1 xcor
     make "y1 ycor
     make "pi 3.14159
     make "amt :radius * :pi / 180
     pu setxy :x :y  fd :radius rt 90 seth :p
     repeat :angle [fd :amt rt 1]
     pu setxy :x1 :y1 seth :p pd
     end

     to "arc.l  :x :y :radius :angle
     local "x1 local "y1 local "p local "amt
     make "x1 xcor
     make "y1 ycor
     make "p heading
     make "amt :radius * :pi / 180
     pu setxy :x :y
     fd :radius lt 90
     seth :p
     repeat :angle [fd :amt lt 1]
     pu setxy :x1 :y1 seth :p pd
     end

     to "circle  :x :y :radius
     local "x1 local "y1 local "p local "amt
     make "p heading
     make "x1 xcor
     make "y1 ycor
     make "pi 3.14159
     make "amt :radius * :pi / 180
     pu setxy :x :y setx xcor - :radius seth 0 pd
     repeat 360 [fd :amt rt 1]
     pu setxy :x1 :y1 seth :p
     end

     to "moveto  :x :y
     pu setxy :x :y
     end

     to "line  :x1 :y1 :x2 :y2
     moveto :x1 :y1
     pd setxy :x2 :y2
     end

     to "dist1  :dx :dy
     op sqrt ( :dx * :dx ) + ( :dy * :dy )
     end

     to "dist  :x1 :y1 :x2 :y2
     op dist1 :x1 - :x2 :y1 - :y2
     end
                             - 109 -      

     to "tan:a
     op sin :a / cOS :a
     end
      
     to "radians :d
     output :d * 1.74533E-2
     end

     to "degrees :r
     output :r * 57.2958
     end

     to "area.circle :radius
     make "pi 3.14159
     output pi * :radius * :radius
     end

Miscellaneous Tools
-------------------
     to "setpos :x :y
     setxy :x :y
     end

     to "wait   :seconds
     tone 32000  20 * :seconds
     tone 32000 1  ;above times the wait; this makes us wait
     end

     to "dice 
     op 1 + integer random 6
     end

     to "pr  :list
     print :list
     end


     You may find it convenient to include some of the more common tools in your PROFILE.BUG file.  You can change that
file to load tools and to start procedures automatically.
For example...

        TO PROFILE
        LOAD "PR
        LOAD "WAIT
        LOAD "CIRCLE
        CIRCLE 25 45 50
        PR [WELCOME TO LADYBUG LOGO!]
        END




                             - 110 -

INDEX

ABS, 81                                IFFALSE, 81, 82             AMAZE, 59                              IFTRUE, 81, 82                                                     INTEGER, 80                 BACK (BK), 9                                                       BACKGROUND (BG), 95                    LadyBug editor, 31          Backspace (back-arrow) key, 13         LadyBug Logo, 1             Ball of string, 35                     LEFT (LT), 9                Books                                  List processing, 83           Logo, 101                            Loading procedures, 33      BYE, 11                                Local variables, 46                                                Logo                        Catalog, 34                              fable, 5                  Changing variables, 51                   history, 1                CIRCLE, 40                               LadyBug, 1                Circles, 38                            Logo books, 101             CLEARSCREEN, 11                        Logo Library, 101           Color, 95                              Logo robot, 97              CRAZY.SHAPES, 49                       Loops, 56                   Curves from straight lines, 67                                                                            MAKE, 51                    DEL key, 13                            MAZE, 54, 59                DRAW, 9, 11                            Memory                                                               stack, 57                 Ed                                     Memory stack, 58              Edit, 31                             MYSTERY, 91                 Editor                                                               LadyBug, 31                          NIM, 90                       screen, 31                           NODRAW, 11                  Embedded recursion, 55, 59             NOT, 84                     ENTER, 9                               NUMBER?, 84                 Erase, 33                                                          Error message, 57                      Optical illusions, 63                                                                          Factorials, 62                         PAINT, 96                   FAN, 67                                PALETTE, 95                 Folded paper fun, 98                   Parallelogram, 49           FORWARD (FD), 9                        PC, 95                      Fractals, 61, 62                       PC 0, 13                    Function keys                          PC 1, 13                      editor, 32                           Pencil turtle, 14                                                  PENCOLOR, 13, 95            Global variables, 46                   PENDOWN (PD), 12            GRID, 74                               PENERASE, 13                                                       Pentagon, 37, 42            HEADING, 73                            PENUP (PU), 12              Help screens, 15                       Picture                     Hexagon, 42                              recursion, 60             HIDEBUG (HB), 23                       Polygon procedure, 53       HIDETURTLE (HT), 23                    Polygons, 41, 53            HOME, 9, 16                            POSTCARD, 85                
                             - 111 - 

Primitives, 10                         String art, 69      
Printing graphics, 35                  Subprocedures, 63           Procedures, 27                         Super procedures, 63        Procedures                                                 
  editing, 31                          Tail-end recursion, 
  loading, 33                          TANGRAM, 48         
  reading, 33                          Tangram puzzles, 47 
  saving, 33                           TARGET, 78          
  writing, 27                          Tessellations, 63   
Puzzles                                TEST, 81, 82        
  Tangram, 47                          TEST.RECURSION, 55  
                                       TO procedure name, 2
RANDOM, 80, 81                         TOOLS.BUG, 79       
Reading procedures, 33                 TOPLEVEL, 58        
Rectangles, 24                         TOWER, 59           
Recursion, 54                          Triangles, 22       
Recursion                              Turtle baseball, 16 
  a picture, 60                        Turtle clock, 36    
  embedded, 55                         Turtle headings, 73 
  tail-end, 54                         Turtle shapes, 19   
Recursive procedures, 54               Turtle steps, 10    
REPEAT, 18                             Turtle turns, 10    
REQUEST (RQ), 55                       Turtle's screen, 17 
RIGHT (RT), 9                                              
Robots, 97                             Variables, 45       
Rule of 360, 37                        Variables           
                                         changing, 51      
Saving procedures, 33                    global, 46        
Screen                                   local, 46         
  coordinates, 74                      VINE, 66            
  editor, 31                                               
Screens                                WAIT, 79            
  help, 15                             WINDOW, 16          
SEntence, 84                           WORD, 84            
SENTENCE (SE), 83                      Words and lists, 83 
SETBG, 95                              WRAP, 16            
SETHEADING (SETH), 73                                      
SETPC, 95                              X coordinates, 74   
SETX, 75                               XCOR, 75            
SETXY, 76                                                  
SETY, 75                               Y coordinates, 74   
SHOWTURTLE (SB), 23                    YCOR, 75            
SLINKY, 65                             Young Peoples' Logo 
Soccer ball, 98                           Association (YPLA), 8
Space Bar, 9                                               
SPIDERWEB, 52                          < - less than, 52   
Squares, 19                                                
Stack                                  > - greater than, 52
  memory, 57, 58
Star of David, 42, 43
Stars, 42
STOP, 55

                             - 112 -

