Go to the previous, next section.

## The ` print-Y-axis ` Function

The job of the ` print-Y-axis ` function is to print a label for the vertical axis that looks like this:

```    10 -

5 -

1 -
```

The function should be passed the height of the graph, and then should construct and insert the appropriate numbers and marks.

It is easy enough to see in the figure what the Y axis label should look like; but to say in words, and then to write a function definition to do the job is another matter. It is not quite true to say that we want a number and a tick every five lines: there are only three lines between the `1' and the `5' (lines 2, 3, and 4), but four lines between the `5' and the `10' (lines 6, 7, 8, and 9). It is better to say that we want a number and a tick mark on the base line (number 1) and then that we want a number and a tick on the fifth line from the bottom and on every line that is a multiple of five.

The next issue is what height the label should be. Suppose the maximum height of tallest column of the graph is seven. Should the highest label on the Y axis be `5 -', and should the graph stick up above the label? Or should the highest label be `7 -', and mark the peak of the graph? Or should the highest label be ` 10 - `, which is a multiple of five, and be higher than the topmost value of the graph?

The latter form is preferred. Most graphs are drawn within rectangles whose sides are an integral number of steps long--5, 10, 15, and so on for a step distance of five. But as soon as we decide to use a step height for the vertical axis, we discover that the simple expression in the varlist for computing the height is wrong. The expression is ` (apply 'max numbers-list) `. This returns the precise height, not the maximum height plus whatever is necessary to round up to the nearest multiple of five. A more complex expression is required.

As usual in cases like this, a complex problem becomes simpler if it is divided into several smaller problems.

First, consider the case when the highest value of the graph is an integral multiple of five--when it is 5, 10, 15 ,or some higher multiple of five. In this case, we can use this value as the Y axis height.

A fairly simply way to determine whether a number is a multiple of five is to divide it by five and see if the division results in a remainder. If there is no remainder, the number is a multiple of five. Thus, seven divided by five has a remainder of two, and seven is not an integral multiple of five. Put in slightly different language, more reminiscent of the classroom, five goes into seven once, with a remainder of two. However, five goes into ten twice, with no remainder: ten is an integral multiple of five.

Go to the previous, next section.