Page 23 - Studio-International-January-1974
P. 23

with exactly the same result. Note how
         powerful a device it is that instead of saying
         first 'print the square of i', then 'print the
         square of 2', then 'print the square of 3', we
         need only say, 'print the square of whatever is in
         the cell labelled COST', repeating the same
         instruction every time. All that changes is the   where the cell PEN will hold r as a code for 'pen
         contents of the cell COST. This notion of   down' and o as a code for 'pen up'. We might
         referring to a number by the name on its cell is   also have generalized a step further, and said:
         fundamental to programming, and in fact it is
         something we do all the time ourselves. Saying
         that a carpet is ten feet long and seven feet wide
         is essentially like saying :






                                                  because now we might want to write the sort of
                                                  reiterative programme we looked at earlier, to
                                                  draw a whole series of points. In writing such
                                                  a programme we will now use a shorter notation
                                                  for PUT, so that instead of writing PUT 5 in
                                                  HOZ, we would write HOZ <— 5.
                                                                                            Figure 7
                                                                                            The thing is that any pair of statements which
                                                                                            relate the horizontal coordinate to the vertical in
                                                                                            a coherent way will produce some sort of curve,
                                                                                            and it's quite easy at this point to start popping
                                                                                            in all kinds of trigonometrical functions and
                                                                                            stand back to see what happens. This one was
                                                                                            written by a passing computer-science student —
                                                                                            I hesitate to say 'invented', since it is almost
                                                                                            entirely a matter of chance whether it will
                                                                                            produce anything pretty, which I think it
                            •
                                                                                            does.
         the important thing here is the level of
         generality, since the programme will now work
         for whatever values we put in the cells labelled
         LENGTH and WIDTH.
          We should be able to get the drawing
         machine to draw something now. You will
         probably remember the idea that you can
         describe the position of any point on a sheet of
         paper by two distances, or coordinates : how far
         the point is horizontally from the left hand edge
         and how far it is vertically from the bottom.
         Suppose we were to reserve two cells labelled
         HOZ and VERT for storing the two
         coordinates for any point to which we wanted
         the pen to go. If the pen is sitting in the bottom   Figure 6
         left hand corner, and our programme says :
                                                  Not a very exciting drawing, but it does
                                                   illustrate a lot of principles. You might be
                                                  surprised by the statement
                                                                     <-- HOZ + 5
                                                               HOZ
                                                  but of course this isn't algebra, and it isn't an
                                                  equation. It means, simply, 'take what was in
                                                  the cell labelled HOZ, add .5 to it and put it
         the computer will recognize from the command   back in the same cell'. The pen has drawn a
         MOVE that it must send its instructions to the   series of ten short line segments which in this
         drawing machine, not to the teletype, and will   case make up a straight line: and has then
        thus send out the commands required to make   lifted and gone back to the bottom left hand
        the pen move to the centre of the bed. The only   corner. The same general form will draw lines
        problem with this programme is that it didn't   which are not straight, if we can simply think
        specify whether the pen was to be down or up.   of a way of generating the appropriate pairs of
         The programme should probably have read:   coordinates. For example:                Figure 8
                                                                                                                                 13
   18   19   20   21   22   23   24   25   26   27   28