Web Turtle - Variables and Equations

Using variables is just like using normal numbers (called "constants")...

If you want to turn right 10 degrees, for example, you would write:
RIGHT 10

If you want to turn right "A" degrees - that is, "the number that's stored in 'A'" degrees, you would write:
RIGHT A

To put a number "into" the variable "A", you use the LET command:
LET A 10

Since "10" is a number, we can replace it with another variable:
LET A B
(This copies the number that's in "B" right now into variable "A.")

If you want to change a variable or do some math, Web Turtle supports a very simple math syntax:

LET A 1+1
Puts the value of (1+1), or 2, into "A."

LET A B+1
Puts the value of (B+1) into "A."

LET A A+1
Puts the value of (A+1) into "A," thus incrementing A by 1.

LET A 10-5
Puts the value of (10-5), or 5, into "A."

LET A 15/5
Puts the value of (15/5), or 3, into "A."
LET A 12/5
Puts the whole value of (12/5) — the whole part of 2.4, or 2 — into "A."
Note: Web Turtle currently only deals with 'integer' numbers (or 'whole' numbers).

LET A 12%5
Puts the remainder of (12/5), or 2, into "A."

LET A 1?10
Picks a random number between 1 and 10, and puts it into "A."

LET A 10/2-1
Puts the value of (10/(2-1)), or 10, into "A." Note, this example shows that Web Turtle has no operator presidence! All operations occur from right to left!


"Web Turtle," created by Bill Kendrick, 1997-2017.