summaryrefslogtreecommitdiff
path: root/web/glasgow/lit2x-0.16/literate/leathrum_on_pgm_typesetting.tex
blob: fc99506efe15209f8f8951403b979067f5c90614 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
% From: leathrum@dartmouth.edu (Thomas E. Leathrum)
% Newsgroups: comp.text.tex
% Subject: Re:  WEB
% Date: 26 Feb 90 00:44:03 GMT
% Organization: Dartmouth College, Hanover, NH
% 
% I haven't been paying a whole lot of attention to the messages about 
% typesetting computer programs, but one I read had an interesting idea:  reverse
% the typefaces, leaving reserved words in plain face and putting variable and 
% procedure names in boldface instead.  (The argument went something like this:  
% reserved words are a computer language's fancy idea of punctuation, and besides
% not really as important as the variables and such, so why not turn things
% around?)  Well, I tried this idea out by typesetting a little procedure from
% Jensen and Wirth's Pascal User Manual and Report, and I'm convinced -- it
% really looks better!  So, for your perusal, I enclose below a little plainTeX
% file with a Pascal procedure to find and print the largest and smallest entries
% in an array of n integers.
% 
% Regards,
% Tom Leathrum
% moth@dartmouth.edu
% 
% ---------------------------------------
% 
% >From Program 11.1 p.68 in 2nd edition
% 
\+ procedure {\bf minmax};\cr
\+ var {\bf i}: 1..{\bf n};\cr
\+ \quad {\bf u}, {\bf v}, {\bf min}, {\bf max}: integer;\cr
\+ begin\cr
\+ \quad {\bf min}$:=${\bf a}[1];\cr
\+ \quad {\bf max}$:=${\bf min};\cr
\+ \quad while {\bf i}$<${\bf n} do\cr
\+ \quad begin\cr
\+ \quad \quad {\bf u}$:=${\bf a}[{\bf i}];\cr
\+ \quad \quad {\bf v}$:=${\bf a}[{\bf i}$+1$];\cr
\+ \quad \quad if {\bf u}$>${\bf v} then\cr
\+ \quad\quad begin\cr
\+ \quad \quad\quad if {\bf u}$>${\bf max} then {\bf max}$:=${\bf u};\cr
\+ \quad \quad\quad if {\bf v}$<${\bf min} then {\bf min}$:=${\bf u};\cr
\+ \quad\quad end;\cr
\+ \quad \quad else\cr
\+ \quad\quad begin\cr
\+ \quad \quad\quad if {\bf v}$>${\bf max} then {\bf max}$:=${\bf v};\cr
\+ \quad \quad\quad if {\bf u}$<${\bf min} then {\bf min}$:=${\bf u};\cr
\+ \quad\quad end;\cr
\+ \quad \quad {\bf i}$:=${\bf i}$+2$;\cr
\+ \quad end;\cr
\+ \quad if {\bf i}$=${\bf n} then\cr
\+ \quad \quad if {\bf a}[{\bf n}]$>${\bf max} then 
                    {\bf max}$:=${\bf a}[{\bf n}];\cr
\+ \quad else\cr
\+ \quad \quad if {\bf a}[{\bf n}]$<${\bf min} then 
                    {\bf min}$:=${\bf a}[{\bf n}];\cr
\+ \quad {\bf writeln}({\bf min}, {\bf max});\cr
\+ \quad {\bf writeln};\cr
\+ end;\cr

\end