Tymless Tutorial: Reference



   
  < walk commands

Turn Commands

 
other commands >
 

Drawing

Control

Data

Reference

 

The 'turn' commands tell the turtle to rotate left or right

left < turn left
right > turn right

They can be used alone, in which case the turtle turns the angle-of-turn held in $>. For example this program...

| > |

...draws two lines at right-angles to each other, because the default angle-of-turn is pi/2 radians (90 degrees).

The turn commands can also be combined with other characters to change the angle turned. Each combination forms a single Tymless keyword:

: n turn n radians
* n turn $> times n radians
/ n turn $> divided by n radians
+ n turn $> plus n radians
- n turn $> minus n radians
= n first change $> to n, then turn $> radians
*= n first multiply $> by n, then turn $> radians
/= n first divide $> by n, then turn $> radians
+= n first add n to $>, then turn $> radians
-= n first subtract n from $>, then turn $> radians

For example:

| >/2 | < | >=$pi/3 | <:1 | > |

This program draws a chain of six lines, and turns alternately right and left between each one. The angle of turn varies in each case:

  • The first angle is $pi/4
  • The second angle is $pi/2 (the default. $> has not yet been changed)
  • The third angle is $pi/3
  • The fourth angle is 1 radian
  • The last angle is $pi/3 ($> was changed by the third turn command)

Two other commands related to turning are:

about-face ! face the opposite direction
flip ~ swap the meaning of left and right. If used twice the original meaning is restored.

Both of these can be used in combination commands:

~* n equivalent to n successive flips. If n is odd, swap the meaning of left and right, otherwise no effect.
!* n equivalent to n successive about-faces. If n is odd, face the opposite direction, otherwise no effect.
!: location face location
!: direction face direction
!? location Query direction: makes no change to the turtle but returns the direction to location from here (see also query-distance)

 

   
  < walk commands
 
other commands >