Go to the first, previous, next, last section, table of contents.


Sample Karel Program 2

By adding calls to the move and turnleft primitives, this program causes Karel to walk a square, returning to his starting point. Note that in this version of Karel, the '{' and '}' are used for comments, just like Pascal.

{ A simple karel program to walk in a square to the left }

BEGINNING-OF-PROGRAM
  BEGINNING-OF-EXECUTION
    move;
    turnleft;
    move;
    turnleft;
    move;
    turnleft;
    move;
    turnleft;
    turnoff
  END-OF-EXECUTION
END-OF-PROGRAM


Go to the first, previous, next, last section, table of contents.