LOGO Commands 8

These command descriptions were adapted from the Berkeley Logo User Manual, Copyright 1993 by the Regents of the University of California.



GRAPHICS
========

TURTLE MOTION QUERIES
---------------------

HEADING

	outputs a number, the turtle's heading in degrees.


WORKSPACE MANAGEMENT
====================

VARIABLE DEFINITION
-------------------

MAKE varname value

	command.  Assigns the value "value" to the variable named "varname",
	which must be a word.  Variable names are case-insensitive.  If a
	variable with the same name already exists, the value of that
	variable is changed.  If not, a new global variable is created.


CONTROL STRUCTURES
==================

FOR forcontrol instructionlist				(library procedure)

	command.  The first input must be a list containing three or four
	members: (1) a word, which will be used as the name of a local
	variable; (2) a word or list that will be evaluated as by RUN to
	determine a number, the starting value of the variable; (3) a word
	or list that will be evaluated to determine a number, the limit value
	of the variable; (4) an optional word or list that will be evaluated
	to determine the step size.  If the fourth member is missing, the
	step size will be 1 or -1 depending on whether the limit value is
	greater than or less than the starting value, respectively.

	The second input is an instructionlist.  The effect of FOR is to run
	that instructionlist repeatedly, assigning a new value to the control
	variable (the one named by the first member of the forcontrol list)
	each time.  First the starting value is assigned to the control
	variable.  Then the value is compared to the limit value.  FOR is
	complete when the sign of (current - limit) is the same as the sign
	of the step size.  (If no explicit step size is provided, the
	instructionlist is always run at least once.  An explicit step size
	can lead to a zero-trip FOR, e.g., FOR [I 1 0 1] ...)  Otherwise, the
	instructionlist is run, then the step is added to the current value
	of the control variable and FOR returns to the comparison step.

		? for [i 2 7 1.5] [print :i]
		2
		3.5
		5
		6.5
		?


DATA STRUCTURE PRIMITIVES
=========================

CONSTRUCTORS
------------

ARRAY size
(ARRAY size origin)

	outputs an array of "size" members (must be a positive integer),
	each of which initially is an empty list.  Array members can be
	selected with ITEM and changed with SETITEM.  The first member of
	the array is member number 1 unless an "origin" input (must be an
	integer) is given, in which case the first member of the array has
	that number as its index.  (Typically 0 is used as the origin if
	anything.)  Arrays are printed by PRINT and friends, and can be
	typed in, inside curly braces; indicate an origin with {a b c}@0.

SELECTORS
---------

ITEM index thing

	if the "thing" is a word, outputs the "index"th character of the
	word.  If the "thing" is a list, outputs the "index"th member of
	the list.  If the "thing" is an array, outputs the "index"th
	member of the array.  "Index" starts at 1 for words and lists;
	the starting index of an array is specified when the array is
	created.

MUTATORS
--------

SETITEM index array value

	command.  Replaces the "index"th member of "array" with the new
	"value".  Ensures that the resulting array is not circular, i.e.,
	"value" may not be a list or array that contains "array".

QUERIES
-------

COUNT thing

	outputs the number of characters in the input, if the input is a word;
	outputs the number of members in the input, if it is a list
	or an array.  (For an array, this may or may not be the index of the
	last member, depending on the array's origin.)


Mtht420