?he 'ARITH0''Page %'
.fo 'Max Clowes'- % -'31st May, 1977'
.de pg
.sp
.tp 5
..
.ce2
Addresses, Lists and Counting
.br
-----------------------------
.sp2
In this demo I'd like to explore some images of counting. They may
overlap a little with
NUMBERS
and with
ARITH1
but no matter. Let's begin by assuming a list of number names:
 	: [ONE .... NINE] -> NUMBERS;
.br
.sp
We have one way of moving down this list:-
.br
:	TL(LIST)->LIST
.br
'destroys' the list but we can circumvent that by making a copy
and 
DESTROYING THE COPY
e.g.
 	: NUMBERS -> NUMS;
.br
(leaves the original intact)
 	: UNTIL	NUMS = []
 	: THEN	HD(NUMS) =>
 	:  	TL(NUMS) -> NUMS;
 	: CLOSE;
.br
.pg
This is the 'standard' way to move down a list ... to 'TL' it.
However it might be closer to our intuitive sense of what WE do
if we think of the 
business of reciting the number names as moving a mental finger from
one 'place` to the next: what we need to do is to keep the
ADDRESS
of the next item in the list in
PLACE.
We'll need to begin by putting the first item there:
 	: NUMBERS -> PLACE;
.br
Now we want to get the number name thats 'in` that item - it is kept
in the head:
 	: HD(PLACE) =>
.br
The item also contains the address of the list item that follows
it; ITS address is kept in the TAIL of the item.
So
TL(ITEM)
will get the new place name that we want to keep in
PLACE
 	: TL(PLACE) -> PLACE;
.br
now we can get the head of this new item by saying
:	HD(PLACE)=>
.br
and so on. The 'and so on' is of course a 'loop' which we want to
go round until there are no more list items. That will be true when
 	: PLACE = []
.br
\&... i.e. there's an empty list in
PLACE.
.sp
So
 	: NUMBERS -> PLACE;
 	: UNTIL	PLACE = []
 	: THEN	HD(PLACE) =>
 	:		TL(PLACE) -> PLACE;
 	: CLOSE;
.br
should do the trick. Try it. Now look back and you will see that
its exactly the same as the original program save for the name
PLACE.
And thats because 'making a copy of something` is nothing more
than putting the
ADDRESS
of that something into the copy place.
.pg
Try moving down a list of 'jelly babies`, e.g. the list that
 	: [* * * *] -> THINGS;
.br
puts into 
THINGS.
.sp
Can you get the computer to recite the number names in step with its
progression down the list of
THINGS?
.pg
These lists are really like nothing you've encountered before unless
it be a toy train where each truck has a place to put things and
a tail to latch onto the next truck. But real jelly babies laid out on
the table to count don't have hooks. And the trouble is that this
computer doesn't have fingers or eyes to explore what it would be like
to count real jelly babies. But we can get a bit nearer to natural
collections of objects by using the turtle to make a picture of a
collection of jelly babies. You might begin by
JUMPing the turtle about the picture doing a
DRAW(1);
here and there before trying to incorporate that into
a turtle program that will take
THINGS
and lay them out in a picture:
 	: FUNCTION LAYOUT(THINGS);
 	:	TURTLE();
 	:	UNTIL	...
 	:	THEN	...
 	:	CLOSE;
 	:	DISPLAY();
 	: END;
.br
.pg
And now comes the hard part. Suppose we have got a picture with
its layout of 'jelly babies'. Could we count them? Well again we
are up against the problem of getting the computer to 'see` what's
in 
PICTURE.
Getting computers to see is a complex business that has little or
nothing to do with getting light into the machine (though
attaching a TV camera to the computer is the standard way to do that).
Rather its the problem of attending to an enormously large
collection of separate bits of information in a picture. That's what
the human retina does ... each of its 100 million cells 'samples`
a tiny patch of the visual scene and conveys that information to
the brain. We have that sampling ability available to us in POP11,
try
 	: PICTURE(1,1) =>
 	: PICTURE(2,2) =>
.br
be sure to make the location (e.g. 1,1) correspond to the
position of a jelly baby.
.pg
So one way to count the number of jelly babies in the picture would
be to look at every point there. Try to think how you'd look at
every point in one line of the picture. Write out the location numbers
for all those points in the line. Now see if you can collapse those
location numbers into some sort of repeated increment, e.g.
the numbers between 1 and 5 are printed by the following:
 	: 1 -> X;
 	: REPEAT 5 TIMES
 	:	X =>
 	:	X + 1 -> X;
 	: CLOSE;
.br
try it.
.br
Of course the location numbers have an X part and a Y part.
 	: REPEAT 5 TIMES
 	:	PICTURE (X,Y) =>
 	:	X + 1 -> X;
 	: CLOSE; 
.br
be sure to give X and Y some starting values.
.pg
Now if you spaced out your 'jelly babies` most of the
PICTURE(X,Y)'s are going to be empty spaces. We want
to ignore them for the purpose of counting and only recite the next
number if 
.tp3
PICTURE(X,Y)
is not a space:
 	: IF	PICTURE(X,Y) /= SPACE
 	: THEN	HD(PLACE) =>
 	: CLOSE;
.br
and we need to step on one both in our list of NUMBERS
i.e.
 	: TL(PLACE) -> PLACE;
.br
and in the picture too:-
.br
 	: IF	PICTURE(X,Y) /= SPACE
 	: THEN	HD(PLACE) =>
 	:	TL(PLACE) -> PLACE;
 	:	X + 1 -> X;
 	: CLOSE;
.pg
Can you put that into a 
REPEAT
loop remembering to start off X and Y with some appropriate
numbers and
PLACE
with the address of
NUMBERS.
Don't forget that the
REPEAT
needs its own
CLOSE
in addition to the one belonging to the IF. Try it out ...
.pg
There are of course remaining problems! How do we know
WHERE
to look in the picture? Where should we look after we've found a jelly baby'?
Are there ways of organising this 'ticking off` of 'jelly babies's that we're
doing? Can we devise a method of ensuring against counting the same
object twice?
.pg
The central problems here of perceptual search, task organisation,
housekeeping ... are complex and you shouldn't feel crushed by not
knowing where to begin. It might help to recall some of
Piaget's work counting jelly babies and the characteristic errors
in estimating that children make. Other aspects of the use that
children ('incorrectly`) make of picture organisation crop up in
attempts to get a child to copy a diamond shape or to draw a glass
of water where the glass is tilted sideways.
.pg
But to return to our original initiative we have now got something,
namely the layed out picture, that is much closer to 'the real thing`
than the list
THINGS
is. Or is it? What are the differences between counting
THINGS
in a list and
THINGS
in a picture?
