LOGO Commands 5

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




ARITHMETIC
==========

NUMERIC OPERATIONS
------------------

SUM num1 num2
(SUM num1 num2 num3 ...)
num1 + num2

	outputs the sum of its inputs.

DIFFERENCE num1 num2
num1 - num2

	outputs the difference of its inputs.  Minus sign means infix
	difference in ambiguous contexts (when preceded by a complete
	expression), unless it is preceded by a space and followed
	by a nonspace.

MINUS num
- num

	outputs the negative of its input.  Minus sign means unary minus if
	it is immediately preceded by something requiring an input, or
	preceded by a space and followed by a nonspace.  There is a difference
	in binding strength between the two forms:

		MINUS 3 + 4	means	-(3+4)
		- 3 + 4		means	(-3)+4

PRODUCT num1 num2
(PRODUCT num1 num2 num3 ...)
num1 * num2

	outputs the product of its inputs.

QUOTIENT num1 num2
(QUOTIENT num)
num1 / num2

	outputs the quotient of its inputs.  The quotient of two integers
	is an integer if and only if the dividend is a multiple of the divisor.
	(In other words, QUOTIENT 5 2 is 2.5, not 2, but QUOTIENT 4 2 is
	2, not 2.0 -- it does the right thing.)  With a single input,
	QUOTIENT outputs the reciprocal of the input.

REMAINDER num1 num2

	outputs the remainder on dividing "num1" by "num2"; both must be
	integers and the result is an integer with the same sign as num1.

MODULO num1 num2

	outputs the remainder on dividing "num1" by "num2"; both must be
	integers and the result is an integer with the same sign as num2.

INT num

	outputs its input with fractional part removed, i.e., an integer
	with the same sign as the input, whose absolute value is the
	largest integer less than or equal to the absolute value of
	the input.

	Note:  Inside the computer numbers are represented in two different
	forms, one for integers and one for numbers with fractional parts.
	However, on most computers the largest number that can be represented
	in integer format is smaller than the largest integer that can be
	represented (even with exact precision) in floating-point (fraction)
	format.  The INT operation will always output a number whose value
	is mathematically an integer, but if its input is very large the output
	may not be in integer format.  In that case, operations like REMAINDER
	that require an integer input will not accept this number.

ROUND num

	outputs the nearest integer to the input.

SQRT num

	outputs the square root of the input, which must be nonnegative.

POWER num1 num2

	outputs "num1" to the "num2" power.  If num1 is negative, then
	num2 must be an integer.

EXP num

	outputs e (2.718281828+) to the input power.

LOG10 num

	outputs the common logarithm of the input.

LN num

	outputs the natural logarithm of the input.

SIN degrees

	outputs the sine of its input, which is taken in degrees.

RADSIN radians

	outputs the sine of its input, which is taken in radians.

COS degrees

	outputs the cosine of its input, which is taken in degrees.

RADCOS radians

	outputs the cosine of its input, which is taken in radians.

ARCTAN num
(ARCTAN x y)

	outputs the arctangent, in degrees, of its input.  With two
	inputs, outputs the arctangent of y/x, if x is nonzero, or
	90 or -90 depending on the sign of y, if x is zero.

RADARCTAN num
(RADARCTAN x y)

	outputs the arctangent, in radians, of its input.  With two
	inputs, outputs the arctangent of y/x, if x is nonzero, or
	pi/2 or -pi/2 depending on the sign of y, if x is zero.

	The expression 2*(RADARCTAN 0 1) can be used to get the
	value of pi.

ISEQ from to						(library procedure)

	outputs a list of the integers from FROM to TO, inclusive.

		? show iseq 3 7
		[3 4 5 6 7]
		? show iseq 7 3
		[7 6 5 4 3]

RSEQ from to count					(library procedure)

	outputs a list of COUNT equally spaced rational numbers
	between FROM and TO, inclusive.

		? show rseq 3 5 9
		[3 3.25 3.5 3.75 4 4.25 4.5 4.75 5]
		? show rseq 3 5 5
		[3 3.5 4 4.5 5]


GRAPHICS
========

Berkeley Logo provides traditional Logo turtle graphics with one turtle.
Multiple turtles, dynamic turtles, and collision detection are not supported.
This is the most hardware-dependent part of Logo; some features may exist
on some machines but not others.  Nevertheless, the goal has been to make
Logo programs as portable as possible, rather than to take fullest advantage
of the capabilities of each machine.  In particular, Logo attempts to scale
the screen so that turtle coordinates [-100 -100] and [100 100] fit on the
graphics window, and so that the aspect ratio is 1:1, although some PC screens
have nonstandard aspect ratios.

The center of the graphics window (which may or may not be the entire
screen, depending on the machine used) is turtle location [0 0].  Positive
X is to the right; positive Y is up.  Headings (angles) are measured in
degrees clockwise from the positive Y axis.  (This differs from the common
mathematical convention of measuring angles counterclockwise from the
positive X axis.)  The turtle is represented as an isoceles triangle; the
actual turtle position is at the midpoint of the base (the short side).

Colors are, of course, hardware-dependent.  However, Logo provides partial
hardware independence by interpreting color numbers 0 through 7 uniformly
on all computers:

	0  black	1  blue		2  green	3  cyan
	4  red		5  magenta	6  yellow	7 white

Where possible, Logo provides additional user-settable colors; how many
are available depends on the hardware and operating system environment.
If at least 16 colors are available, Logo tries to provide uniform
initial settings for the colors 8-15:

	 8  brown	 9  tan		10  forest	11  aqua
	12  salmon	13  purple	14  orange	15  grey

Logo begins with a black background and white pen.


TURTLE AND WINDOW CONTROL
-------------------------

SHOWTURTLE
ST

	makes the turtle visible.

HIDETURTLE
HT

	makes the turtle invisible.  It's a good idea to do this while
	you're in the middle of a complicated drawing, because hiding
	the turtle speeds up the drawing substantially.


PEN AND BACKGROUND CONTROL
--------------------------

SETPENCOLOR colornumber
SETPC colornumber

	sets the pen color to the given number, which must be a nonnegative
	integer.  Color 0 is always black; color 7 is always white.  Other
	colors may or may not be consistent between machines.

SETBACKGROUND color
SETBG color

	set the screen background color.



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


INSPECTION
----------

PO contentslist

	command.  Prints to the write stream the definitions of all
	procedures, variables, and property lists named in the input
	contents list.


WORKSPACE CONTROL
-----------------

EDIT contentslist
ED contentslist
(EDIT)
(ED)

	command.  If invoked with an input, EDIT writes the definitions
	of the named items into a temporary file and edits that file, using
	your favorite editor as determined by the EDITOR environment
	variable.  If you don't have an EDITOR variable, edits the
	definitions using jove.  If invoked without an input, EDIT edits
	the same file left over from a previous EDIT or EDITFILE instruction.
	When you leave the editor, Logo reads the revised definitions and
	modifies the workspace accordingly.  It is not an error if the
	input includes names for which there is no previous definition.

	If there is an environment variable called TEMP, then Logo uses
	its value as the directory in which to write the temporary file
	used for editing.

	Exceptionally, the EDIT command can be used without its default
	input and without parentheses provided that nothing follows it on
	the instruction line.


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

WAIT time

	command.  Delays further execution for "time" 60ths of a second.
	Also causes any buffered characters destined for the terminal to
	be printed immediately.  WAIT 0 can be used to achieve this
	buffer flushing without actually waiting.

BYE

	command.  Exits from Logo; returns to the operating system.


Mtht420