[Inquiry] Re: Theme One Program -- Commentary Notes
Jon Awbrey
jawbrey at oakland.edu
Tue Mar 18 18:14:40 CST 2003
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
TOP. Commentary Note 8
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
Tap.
Tap is a function from text files to characters.
It takes a character off the input stream and
reports it as its current functional value,
thereby serving as a read operation.
Nota Bene. In this version of Pascal, variables with file types,
for example, text files, must be declared as variable parameters.
One way to think of variable parameters in functional terms is to
regard them as being listed on both sides of the functional arrow.
In this way of seeing things, Tap would be a function from texts
to a product of texts with characters, Tap : Text -> Text x Char.
function tap (var thou: text): char;
var mark: char;
begin
read (thou, mark);
tap := mark
end;
(5214)(7554)
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
Pat.
Pat is a function from text files and characters to characters.
It puts a character on the output stream and reports it as its
current functional value, thereby serving as a write operation,
plus an echo of the written character in the functional result.
Nota Bene. In this version of Pascal, variables with file types,
for example, text files, must be declared as variable parameters.
One way to think of variable parameters in functional terms is to
regard them as being listed on both sides of the functional arrow.
In this view, Pat is a function from a product of texts and characters
to a product of texts and characters, Pat : Text x Char -> Text x Char.
function pat (var thou: text;
mark: char): char;
begin
write (thou, mark);
pat := mark
end;
(5215)(7555)
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
Apt.
Apt is a function from characters and ideas to ideas.
Its functional value is a nil idea unless its argument
character matches the character in the 'sign' field of
an existing form that is addressed by its argument idea,
in which case its functional value is that same address.
In this fashion, reporting a nil idea for "false" and a
non-nil idea for "true", it serves as a primitive test
function that will be called as a basic part of many
other equality, look-up, match, or test functions.
function apt (mark: char;
this: idea): idea;
var here: idea;
begin
here := nil;
if this <> nil then
if mark = this^.sign then here := this;
apt := here
end;
(5216)(7556)
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
More information about the Inquiry
mailing list