_____________________________________________________________
+, *, -, /, <, >, =, <=, >=, ^
All of these operators take two inputs, and all act as "infix operators" (going between the
two inputs, as in standard mathematical use).
Note: ^ (exponentiation) is currently implemented only for the observer.
_____________________________________________________________
abs number
Reports the absolute value of number.
Example:
fd abs -7
(Turtles move forward 7 steps.)
_____________________________________________________________
boolean1 and boolean2
Reports true if both boolean1 and boolean2 are true. Note that and
is "infix": it comes between its two inputs.
Example:
if (ycor > 0) and (xcor > 0) [setpc blue]
(The upper-right quadrant of patches turn blue.)
_____________________________________________________________
atan y x
(Both x and y must be numbers)
Reports the arctangent, in degrees (from 0 to 360), of y divided by x. (Note: atan
is accurate to only one or two decimal places.)
Example:
show atan 1 -1
(Prints 135.0 to the command center.)
show atan -1 1
(Prints 315.0 to the command center.)
_____________________________________________________________
bitand number1 number2
bitor number1 number2
bitneg number
bitxor number1 number2
bitand reports the bitwise and of its two inputs. bitor reports the
bitwise or of its two inputs. bitneg reports the bitwise negation of
its input. bitxor takes the bitwise xor of two numbers as inputs.
(For best results, inputs should be limited to 16-bit integers.)
_____________________________________________________________
cos angle
Reports the cosine of angle. Assumes angle is given in degrees.
Example:
show cos 180
(Prints -1.0 in the command center.)
_____________________________________________________________
e
2.718
_____________________________________________________________
exp number
Reports the value of e raised to the number power.
_____________________________________________________________
int number
Reports the largest integer less than or equal to number.
_____________________________________________________________
ln number
Reports the natural logarithm of number.
_____________________________________________________________
max number1 number2
Returns the maximum of the two numbers.
_____________________________________________________________
maxint
32,767
_____________________________________________________________
maxnum
32767.99998 (or 32767 65535/65536)
_____________________________________________________________
min number1 number2
Returns the minimum of the two numbers.
_____________________________________________________________
minint
-32,768
_____________________________________________________________
minnum
-32768.0
_____________________________________________________________
number1 mod number2
Reports number1 modulo number2 : that is, the remainder when number1
is divided by number2. Note that mod is "infix": it comes between its two inputs.
Example:
show 62 mod 5
(Prints 2 to the command center.)
_____________________________________________________________
not boolean
Reports true if boolean evaluates to false. Reports false
if boolean evaluates to true.
Example:
if not color = blue [fd 10]
(All non-blue turtles move forward 10 steps.)
_____________________________________________________________
boolean1 or boolean2
Reports true if either boolean1 or boolean2 evaluates to true.
Note that or is "infix": it comes between its two inputs.
Example:
if (xcor > 0) or (ycor > 0) [setpc red]
(All patches turn red, except those in the lower-left quadrant.)
_____________________________________________________________
pi
3.14159
_____________________________________________________________
random number
Reports an integer between 0 and number, including 0 but not number.
_____________________________________________________________
round number
Reports the integer nearest to number.
_____________________________________________________________
sin angle
Reports the sine of angle. Assumes angle is given in degrees.
_____________________________________________________________
sqrt number
Reports the square root of number.
_____________________________________________________________
tan angle
Reports the tangent of angle. Assumes angle is given in degrees.
_____________________________________________________________
xor boolean1 boolean2
Reports the value of boolean1 xor boolean2.
=============================================================