In the first post on Cistercian Numbers, I covered drawing the Cistercian numerals zero through four using ucblogo (Berkeley Logo). Five was left as a future exercise with the point that it’s possible to think of five as the result of combining drawing both four and one:

In this post, we’ll dive into an approach to drawing certain numerals as combinations of other numerals.

To describe the challenge in a bit more detail – if the commands for drawing four and one are simply run one after the other:

```
TO Draw.5
Draw.4
Draw.1
END
```

The result is interesting; but, it is not the numeral for five:

In order to layer the two numerals properly, we need a way to reset the turtle’s position between drawing the two numerals:

The approach taken in this post is to write two new commands – `Save.Turtle`

and `Restore.Turtle`

.

The `Save.Turtle`

command will save the turtle’s position and heading. We’ll call this prior to drawing the first numeral so the turtle remembers where it was before drawing anything. This way, the turtle can return to its starting position and heading from any other position and heading on the screen:

```
To Save.Turtle
MAKE "Saved.Turtle (LIST POS HEADING)
END
```

Walking through the code:

`POS`

– outputs the turtle’s current position`HEADING`

– outputs the turtle’s current heading in degrees.`LIST`

– outputs a list, with the turtle’s position as the first member and the turtle’s heading as the last member.`MAKE`

– assigns the above list value to the variable named`Saved.Turtle`

The `Restore.Turtle`

command will go back to the saved position. We’ll call this prior to drawing any additional numerals. This way, the numerals will draw precisely on top of each other so they combine as expected:

```
To Restore.Turtle
PU
SETPOS FIRST :Saved.Turtle
SETHEADING LAST :Saved.Turtle
PD
END
```

Walking through the code:

`PU`

– lift the pen, so the turtle does not draw while moving`FIRST`

– outputs the first member of the list`Saved.Turtle`

`SETPOS`

– moves the turtle to the position returned from`FIRST`

`LAST`

– outputs the last member of the list`Saved.Turtle`

`SETHEADING`

– turns the turtle to a heading in degrees returned from`LAST`

`PD`

– puts the pen back down, so the turtle will draw when next moved

*A possible improvement here would be checking if the pen is up or down using PENDOWN? before calling PU and then restoring the pen to its original state rather than always calling PD.*

Now, we can draw the numeral for five thusly:

```
TO Draw.5
Save.Turtle
Draw.4
Restore.Turtle
Draw.1
END
```

This is a good breakpoint as the numeral for six is a new base shape. In the next post we’ll teach the turtle to draw six, we can teach it to draw seven, eight, and nine using the numerals for six, one, and two: