WorldTurtle and LOGO have differing coordinate systems.
In LOGO, North is at 0°, and the heading increments clockwise.
In WorldTurtle, East is at 0°, and the heading increments counter-clockwise.
LOGO | TurtleCommand s |
---|---|
FORWARD X (or FD X ) |
forward X (or fd X ) |
BACK X (or BK X ) |
backward X (or bk X ) |
LEFT X (or LT X ) |
left X (or lt X ) |
RIGHT X (or RT X ) |
right X (or rt X ) |
PENDOWN (or PD ) |
setPenDown |
PENUP (or PU ) |
setPenUp |
SHOWTURTLE (or ST ) |
setVisible |
HIDETURTLE (or ST ) |
setInvisible |
SETPENSIZE [X Y] |
setPenSize X |
HOME |
home |
LABEL S |
label S |
WAIT x |
wait X |
SETXY X Y |
goto (X, Y) |
ARC A R |
arc a r |
SETX X |
position >>= \(_, y) -> goto (X, y) |
SETY Y |
position >>= \(x, _) -> goto (x, Y) |
POS |
position |
XCOR |
fst <$> position |
YCOR |
snd <$> position |
SETHEADING X (or SETH X ) |
setHeading X |
LOGO | WorldCommand s |
---|---|
CLEARSCREEN (or CS ) |
clear |
CLEARTEXT |
N/A |
In LOGO, repetition is done via lists such as:
REPEAT X [COMMAND1 COMMAND2 COMMAND3]
In WorldTurtle, repetition is performed on one TurtleCommand
, which can be composed of other
commands using the (>>)
operator.
repeatFor X (command1 >> command2 >> command3)
You can also use do-notation to achieve the same effect:
repeatFor X $ do
command1
command2
command3
In LOGO, procedures are written between to
/end
statements.
TO SQUARE
REPEAT 4 [FD 100 RT 90]
END
In Haskell everything is a function; there is no special syntax for procedures. (But do remember that indentation is important!)
square = repeatFor 4 $ fd 100 >> rt 90
In do-notation:
square = do
repeatFor 4 $ do
fd 100
rt 100
Note that in Haskell, types can be implicitly calculated by the compiler, it is good practice to write a type declaration:
square :: TurtleCommand ()
square = repeatFor 4 $ fd 100 >> rt 90
Both LOGO and Haskell functions can take arguments which follow the declaration name.
TO SQUARE :n
REPEAT 4 [FD :n RT 90]
END
square :: Float -> TurtleCommand ()
square n = repeatFor 4 $ fd n >> rt 90