Using variables
Text window or Edit window?
You
can usually create variables in either conversational mode (in
the text window) or in editing mode (in the edit window). In conversational mode,
you need to make sure that you hit <enter> or <return> (whichever
your system requires) at the end of a line for LOGO to take notice of that line.
There is no feedback when
using make. On the other hand, in editing mode, you can type
a series of lines each followed by <return> and each perhaps creating some
different variable. If at some point you then hit the key you use to escape
from the editor, LOGO will try to interpret all of the lines you have typed and
will then return you to the text window to continue normal conversation. It follows
that if you just want to set up a variable or two, you would normally do
this in conversational mode but
if you are setting up a whole series of variables, then the editor is more appropriate.Setting up and using variables
Create a number of different variables using make
and then use them in conjunction with some of the primitive procedures
you have learnt so far. E.g. type: make "shopping [bread butter cheese milk]
and then use the variable in expressions with last, first,
butfirst, fput etc. in various combinations. You could also try the primitive
item.
If you need to review the use of these procedures click here.
Retrieving the value of a variable
Practice retrieving the value of a variable with thing
or : (colon). Is thing an operation or a
command?Updating the value of a variable
Try using make to assign a new value
to a variable you have previously created. Use thing to confirm
that the value has been changed.New variables from old
Create some new variables using
existing variables. E.g. You
have a list called "girls representing the girls
in a family and another called "boys representing
the boys. Create a new variable called "children using
these two variables. What is the difference between using se
versus list to do this. Can you imagine circumstances
in which you would find one tactic more useful than the other?4. Experiment
with updating
the value of one of your variables - i.e. modify it on the basis of its current
value (rather than simply change it as in 2). E.g. if you have set up a
variable called "shopping, see if you can change its value
so that it no longer has the original first item on the list (as if you have
just bought it) or change it by adding an item to the end of the original list
(as if you have just remembered something).
What happens to :children
(if you set it up as above above)
when you subsequently update :boys.
Russian dolls
Try making some
nested variables. E.g. make "doll1 "doll2
and so on. Now see if you can find out what is inside the innermost doll using
thing ( and : to the extent that it is allowed).Limits on names
How long can a variable name be in the system you are using? Are
there any characters which are not accepted as part of a variable name (or for
that matter as part of LOGO
word)? Experiment to find out.
Keeping things tidy
For help on managing variables in your workspace, look here.
Ron Brasington
Department of Linguistic Science
The University of Reading
Reading
UK
E-mail: ron.brasington@rdg.ac.uk