[Inquiry] Re: Theme One Program -- Commentary Notes
Jon Awbrey
jawbrey at oakland.edu
Tue Mar 18 20:00:08 CST 2003
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
TOP. Commentary Note 10
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
Nip.
Nip is a function from text files to integers.
It reads an integer code from the input stream
and reports it as its current functional value,
thereby serving as a numerical input operation.
Because it assumes a text file format in which
an integer code is followed by an end-of-line
marker or a blank character, a Tap operation
is used to handle the terminal space, if any.
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, Nip is a function from texts to
texts and integers, Nip : Text -> Text x Numb.
function nip (var thou: text): numb;
var what: numb;
mark: char;
begin
read (thou, what);
if not eoln (thou) then mark := tap (thou);
nip := what
end;
(5220)(7560)
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
Pin.
Pin is a function from text files and integers to integers.
It puts an integer code on the output stream and copies it
to its current functional value, in this way functioning
as a numerical write operation, accompanied by an echo
of the output integer value 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, Pin is a function from a product of texts and integers
to a product of texts and integers, Pin : Text x Numb -> Text x Numb.
function pin (var thou: text;
what: numb): numb;
begin
write (thou, what, blank);
pin := what
end;
(5221)(7561)
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
More information about the Inquiry
mailing list