diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-09 00:44:40 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-09 00:44:40 +0000 |
commit | b4fc5f639874db951177ec539299d20908adb654 (patch) | |
tree | 52f08823ca58fffe3db6a9b075635038c567626c /Master/texmf-dist/doc/latex/apl | |
parent | dec3d98ebe442d7ea93efbaa8dd2e2be8149a467 (diff) |
doc 4
git-svn-id: svn://tug.org/texlive/trunk@80 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/apl')
-rw-r--r-- | Master/texmf-dist/doc/latex/apl/00readme.tex | 32 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/apl/apldef.tex | 96 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/apl/aplstyle.tex | 29 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/apl/aplverb.tex | 45 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/apl/ninesize.tex | 34 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/apl/problems.tex | 316 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/apl/sample.tex | 124 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/apl/solutions.tex | 198 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/apl/tugboat.tex | 530 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/apl/tugboat2.tex | 534 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/apl/versatim.tex | 66 |
11 files changed, 2004 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/apl/00readme.tex b/Master/texmf-dist/doc/latex/apl/00readme.tex new file mode 100644 index 00000000000..d729a540b6a --- /dev/null +++ b/Master/texmf-dist/doc/latex/apl/00readme.tex @@ -0,0 +1,32 @@ +% langs/apl +\par\begin{footnotesize}\begin{alltt} +Contents of README files:\par +Thank you for your letter of 27 February. The original purpose +of our APL font and macros was to solve the immediate problem +of writing documents with APL code. Therefore, they are free for +anyone who finds them useful. Some people have requested the font +and we have sent them the files appended below (with CMAPL10 and +two conversion programs for downloading pixel files, not given here). +Further, we have nothing against giving our net address to the +users because it would be useful to hear about extensions made +to the system. + +The files APLDEF.TEX and TUGBOAT.TEX are identical with the second +versions sent to you (via BITNET) except for minimal changes (there +are some corrections and extensions in APLDEF.TEX, and in +TUGBOAT.TEX one APL line was corrected.) We think the files are +in a "final" form (at least we are not planning any changes). + +Our original purpose was to publish the second version, but the only +difference was really the removal of the tilde space character (this +resulted in more complex 1-character macros, but the user cannot +see any difference; moreover, TeX runs only about 14% slower). Thus, +we feel that there is no reason to publish a list of errata in +TUGboat, because any user would inevitably have to use the new +version (the old one has not been released). + +We are adding a file containing sample examples on the use of the +APL mnemonics. + +Aarno Hohti +\end{alltt}\end{footnotesize}\par diff --git a/Master/texmf-dist/doc/latex/apl/apldef.tex b/Master/texmf-dist/doc/latex/apl/apldef.tex new file mode 100644 index 00000000000..e47ab57301f --- /dev/null +++ b/Master/texmf-dist/doc/latex/apl/apldef.tex @@ -0,0 +1,96 @@ +% apldef.tex +% +%=============================================================== +% This file contains the definitions of the 2-letter control +% sequences for using cmapl10. +%=============================================================== +% +\def\RO{{\apl\char'014}} % rho +\def\IO{{\apl\char'015}} % iota +\def\BX{\lower.1ex\hbox{\apl\char'001}} % quad box (window etc.) +\def\CE{{\apl\char'035}} % ceiling +\def\FL{{\apl\char'034}} % floor +\def\DE{{\apl\char'031}} % decode +\def\EN{{\apl\char'030}} % encode +\def\DL{{\apl\char'002}} % del +\def\LD{{\apl\char'003}} % delta +\def\NT{{\apl\char'026}} % not +\def\LO{{\apl\char'017}} % circle +\def\GO{{\apl\char'036}} % arrow right +\def\OR{{\apl\char'010}} % logical or +\def\DM{{\apl\char'011}} % diamond +\def\LE{{\apl\char'012}} % less than or equal +\def\GE{{\apl\char'013}} % greater than or equal +\def\AB{{\apl\char'174}} % stile +\def\LB{{\apl\char'173}} % left brace +\def\RB{{\apl\char'175}} % right brace +\def\DA{{\apl\char'037}} % arrow down +\def\UA{{\apl\char'136}} % arrow up +\def\EP{{\apl\char'006}} % epsilon +\def\NE{{\apl\char'027}} % not equal +\def\BL{{\apl\char'134}} % backslash +\def\RU{{\apl\char'022}} % right U +\def\LU{{\apl\char'023}} % left U +\def\DU{{\apl\char'021}} % down U +\def\UU{{\apl\char'020}} % up U +\def\LK{{\apl\char'033}} % left tack +\def\RK{{\apl\char'032}} % right tack +\def\US{{\apl\char'024}} % underscore +\def\NG{{\apl\char'025}} % high minus +\def\DD{{\apl\char'007}} % dieresis +\def\AM{{\apl\char'004}} % alpha +\def\OM{{\apl\char'005}} % omega +\def\SO{\raise.3ex\hbox{{\apl\char'016}}} % small circle +% +% This macro is used for overstriking two characters +\newskip\charwidth +\def\overstrike#1#2{\setbox1=\hbox{#1}\charwidth=\wd1 + #1\hskip-\charwidth#2} +% +\def\TR{\overstrike{\LO}{\BL}} % transpose +\def\RV{\overstrike{\LO}{\AB}} % reverse +\def\CR{\overstrike{\LO}{-}} % column reverse +\def\GD{\overstrike{\LD}{\AB}} % grade down +\def\GU{\overstrike{\DL}{\AB}} % grade up +\def\FM{\overstrike{\raise.1ex\hbox{{\apl\char'016}}}{\EN}} % format +\def\XQ{\overstrike{\raise.1ex\hbox{{\apl\char'016}}}{\DE}} % execute +\def\SS{\overstrike{\RU}{\US}} % subset +\def\CO{\overstrike{\LU}{\US}} % contains +\def\CB{\overstrike{\BL}{-}} % column backslash +\def\CS{\overstrike{/}{-}} % column slash +\def\IB{\overstrike{\EN}{\DE}} % I-beam +\def\DQ{\overstrike{{\apl\char'045}}{\BX}} % divide quad +\def\QQ{\overstrike{{\apl '}}{\BX}} % quote quad +\def\PD{\overstrike{\DL}{\NT}} % protected del +\def\NR{\overstrike{\OR}{\NT}} % nor +\def\NN{\overstrike{{\apl\char'046}}{\NT}} % nand +\def\LG{\overstrike{{\apl *}}{\LO}} % logarithm +% underscored letters +\def\ZA{\overstrike{{\apl A}}{\US}} +\def\ZB{\overstrike{{\apl B}}{\US}} +\def\ZC{\overstrike{{\apl C}}{\US}} +\def\ZD{\overstrike{{\apl D}}{\US}} +\def\ZE{\overstrike{{\apl E}}{\US}} +\def\ZF{\overstrike{{\apl F}}{\US}} +\def\ZG{\overstrike{{\apl G}}{\US}} +\def\ZH{\overstrike{{\apl H}}{\US}} +\def\ZI{\overstrike{{\apl I}}{\US}} +\def\ZJ{\overstrike{{\apl J}}{\US}} +\def\ZK{\overstrike{{\apl K}}{\US}} +\def\ZL{\overstrike{{\apl L}}{\US}} +\def\ZM{\overstrike{{\apl M}}{\US}} +\def\ZN{\overstrike{{\apl N}}{\US}} +\def\ZO{\overstrike{{\apl O}}{\US}} +\def\ZP{\overstrike{{\apl P}}{\US}} +\def\ZQ{\overstrike{{\apl Q}}{\US}} +\def\ZR{\overstrike{{\apl R}}{\US}} +\def\ZS{\overstrike{{\apl S}}{\US}} +\def\ZT{\overstrike{{\apl T}}{\US}} +\def\ZU{\overstrike{{\apl U}}{\US}} +\def\ZV{\overstrike{{\apl V}}{\US}} +\def\ZX{\overstrike{{\apl X}}{\US}} +\def\ZY{\overstrike{{\apl Y}}{\US}} +\def\ZW{\overstrike{{\apl W}}{\US}} +\def\ZZ{\overstrike{{\apl Z}}{\US}} + +\endinput diff --git a/Master/texmf-dist/doc/latex/apl/aplstyle.tex b/Master/texmf-dist/doc/latex/apl/aplstyle.tex new file mode 100644 index 00000000000..b732bded0c4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/apl/aplstyle.tex @@ -0,0 +1,29 @@ +% aplstyle.tex +% +%=============================================================== +% A P L S T Y L E +%=============================================================== +% A.Hohti/O.Kanerva University of Helsinki April 6 1987 +% +% APL symbols are represented by the Digital (VAX) APL replacement +% symbols. The standard escape sequence is changed to "@" (at sign) +% in accordance with the usage in Digital APL. +% +\font\apl=cmapl10 % The APL font of typewriter type +% +% +% The following macro switches the typewriter-like font +% used within verbatim +\def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax} +\outer\def\choosett#1{\ifundefined{#1} + \message{Undefined font(?), replaced with cmtt10} + \let\tt=\tentt + \else + \def\tt{\expandafter\csname#1\endcsname}\fi} +% +\choosett{tentt} % default value +% +\input aplverb % definitions for verbatim +\input apldef % control sequences for the APL symbols + +\endinput diff --git a/Master/texmf-dist/doc/latex/apl/aplverb.tex b/Master/texmf-dist/doc/latex/apl/aplverb.tex new file mode 100644 index 00000000000..cac8e3acdbf --- /dev/null +++ b/Master/texmf-dist/doc/latex/apl/aplverb.tex @@ -0,0 +1,45 @@ +% aplverb.tex = verbatim.tex +% +% +% F|ljande macron anv{nds d} man vill f} ut \TeX-kommandon +% i klartext. @text@ ger text i fonten \tt med alla kontroll- +% tecken och dylika bevarade (\TeX\ f|rst}r sig endast p} kommandot +% @ i denna mode). Man kan ocks} utnyttja \begintt ... \endtt f|r +% att beskriva kommandon, d} {r ocks} \obeylines och \obeyspaces +% aktiva. Om man vill anv{nda vissa \TeX-kommandon men vill +% ocks} displaya n}got i en-kolumn-tabell-form kan man anv{nda +% \begindisplay ...\cr ...\cr \enddisplay +% Om du vill anv{nda \begintt...\endtt f|r text som inte +% ryms p} en sida, kan du ocks} anv{nda \beginlines...\endlines. +% Varje rad m}ste d} b|rjas och avslutas med kommandot @. +\newskip\verbatimindent \verbatimindent=0cm +\newskip\ttglue{\tt \global\ttglue=.5em plus.25em minus.15em} +\def\@{\char'100 } +% +\outer\def\begindisplay{\obeylines\startdisplay} +{\obeylines\gdef\startdisplay#1 + {\catcode`\^^M=5$$#1\halign\bgroup&\hskip\verbatimindent##\hfil\cr}} +\outer\def\enddisplay{\crcr\egroup$$} +% +\chardef\other=12 +\def\ttverbatim{\begingroup \catcode`\\=\other \catcode`\{=\other + \catcode`\}=\other \catcode`\$=\other \catcode`\&=\other + \catcode`\#=\other \catcode`\%=\other \catcode`\~=\other + \catcode`\_=\other \catcode`\^=\other\catcode`\*=\other\catcode`\==\other + \obeyspaces \obeylines \tt} +{\obeyspaces\gdef {\ }} +% +\def\begintt{$$\let\par=\endgraf \ttverbatim \parskip=0pt + \catcode`\@=0 \parindent=\verbatimindent \rightskip=-5pc \ttfinish} +{\catcode`\@=0 @catcode`@\=\other % @ is temporary escape character + @obeylines % end of line is active + @gdef@ttfinish#1^^M#2\endtt{#1@vbox{#2}@endgroup$$}} +% +\catcode`\@=\active +{\obeylines\gdef@{\ttverbatim\spaceskip=\ttglue\let^^M=\ \let@=\endgroup}} + +\def\beginlines{\par\begingroup\nobreak\medskip\parindent=0pt + \kern1pt\nobreak \obeylines \everypar{\strut}} +\def\endlines{\kern1pt\endgroup\medbreak\noindent} + +\endinput diff --git a/Master/texmf-dist/doc/latex/apl/ninesize.tex b/Master/texmf-dist/doc/latex/apl/ninesize.tex new file mode 100644 index 00000000000..a0260f07997 --- /dev/null +++ b/Master/texmf-dist/doc/latex/apl/ninesize.tex @@ -0,0 +1,34 @@ + +%============================================================================= +% N I N E S I Z E . T E X (for convenience only) +%============================================================================= +%=============================================================== +% This is a TeX macro for switching to nine point fonts. Taken +% from the TeXbook, pages 413 - 415. (For special cases only) +%=============================================================== +% +\font\ninerm=amr9 +\font\ninei=ammi9 +\font\ninesy=amsy9 +\font\ninebf=ambx9 +\font\ninett=amtt9 +\font\nineit=amti9 +\font\ninesl=amsl9 +% +\skewchar\ninei='177 +\skewchar\ninesy='60 +\skewchar\ninett=-1 +% +\newskip\tglue +\def\ninepoint{\def\rm{\fam0\ninerm} + \textfont0=\ninerm + \textfont1=\ninei + \textfont2=\ninesy + \textfont\itfam=\nineit \def\it{\fam\itfam\nineit}% + \textfont\slfam=\ninesl \def\sl{\fam\slfam\ninesl}% + \textfont\ttfam=\ninett \def\tt{\fam\ttfam\ninett}% + \textfont\bffam=\ninebf \def\bf{\fam\bffam\ninebf}% + \tt\tglue=.5em plus.25em minus .15em + \normalbaselineskip=11pt + \setbox\strutbox=\hbox{\vrule height8pt depth3pt width0pt}% + \let\sc=\sevenrm \let\big=\ninebig \normalbaselines\rm}% diff --git a/Master/texmf-dist/doc/latex/apl/problems.tex b/Master/texmf-dist/doc/latex/apl/problems.tex new file mode 100644 index 00000000000..3f47553ea37 --- /dev/null +++ b/Master/texmf-dist/doc/latex/apl/problems.tex @@ -0,0 +1,316 @@ + +%=================================================================== +% Sample problems; solutions give examples on using APL style in TeX +% Taken from the course ``Mathematics on the Computer'', Fall 87 +%=================================================================== + +\magnification = \magstep1 + +\advance\vsize by 3truecm + +\input mssymb % for some math symbols only! This is the new + % symbol font for some standard and non-standard + % mathematical symbols. It is only used here for + % blackboard bold letters. If you dont have it, + % just define \def\Bbb{} etc. + +\input aplstyle + +\choosett{apl} + +\font\sans = amss10 +\font\sltt = amsltt10 + +\def\header{{\sans Sample problems 9.\ 10.\ 1987}} +% some of them come from Sims' ``Abstract Algebra, A Computational Approach'' +\def\APL{{\sltt APL}} + +\nopagenumbers +\tolerance = 300 +\noindent +\header + +\vskip 2cm + +\item{1.} Let $N>1$ be an integer. Show that each of the following + matrices represents a binary operation on + $S(N)$ (we set locally \BX@IO_0@.) Which of them are + associative, which commutative? + \medskip + + \itemitem{a)} @(@\IO@N)@\SO@.@\CE\IO@N@ + + \itemitem{b)} \AB@(@\IO@N)@\SO@.-@\IO@N@ + + \itemitem{c)} @N@\AB@(@\IO@N)@\SO@.+@\IO@N@ + + \itemitem{d)} @N@\AB@(@\IO@N)@\SO@.#@\IO@N@ + + \medskip +\item{} Here @x@\CE@y@ is $\max(x,y)$, @x@\AB@y@ is + $y\bmod x$ and \AB@x@ is the absolute value of $x$. + +\bigskip + +\item{2.} Write an \APL\ function @GPOWER@ that computes for a group + @G@ (global variable) the $n$-th power of a given element $x$. + (If $S(M)$ is a representation vector of @G@, then + @GPOWER@ is a map $S(M)\times \Bbb Z\to S(M)$. Simply + use iteration.) + +\bigskip + +\item{3.} (Continuing problem 2.) A faster algorithm is obtained by + decomposing $x^n$ into its 2--base form + $x^n = x^{i_0}\times x^{2i_1}\times + x^{4i_2}\times ... \times x^{{2^k}i_k}$, where $i_j\in\{0,1\}$. Show + that the complexity of this algorithm is $O(\log_2(n))$. + (Show that the number of necessary multiplications does + not exceed $2\log_2(n)$). How would you write the corresponding + function in \APL? (Note that the binary representation of $n$ + can be obtained by applying iteratively the procedure $n\bmod 2$.) + +\bigskip + +\item{4.} Write an \APL\ function @GTSGP@ that computes for a given group @G@ + (global variable) the subgroup generated by a given subset $A$. The + function @GTSGP@ has one argument (the vector @A@) and returns + a subset of the set $S(N)$ (as a vector). (Extend the set @A@ + by the group operation until @A@ becomes closed with respect + to the operation.) + +\bigskip + +\item{5.} Write an \APL\ function @INV@ that returns for a group @G@ + the vector of inverse elements as a vector $S(N)\to S(N)$ so + that the index of the inverse of $x_i$ is @(INV G)[I]@. + +\bigskip + +\item{6.} Let $(G,\theta)$ be a group and let $A$ be a subset of $G$. Program + the following algorithm in \APL\ to find the subgroup @H@ + generated by @A@. Compare the perfomance of this algorithm + with the algorithm in Problem 4. + \medskip + + \itemitem{a)} put $H$ and $Y$ equal to $\{e\}$. + + \itemitem{b)} let $Y$ be $YA\smallsetminus H$. + + \itemitem{c)} if $Y=\emptyset$, stop. + + \itemitem{d)} put $H$ equal to $H\cup Y$ and + go to (b). + + \medskip +\item{} ($e$ is the neutral element and $YA\smallsetminus H$ + is the set--theoretical difference of $YA$ and $H$. + The product $YA$ is the set $\{y\theta a: y\in Y, a\in A\}$.) + +\bigskip + +\item{7.} Write an \APL\ function @PROD@ that returns for given groups + $(G_1,\theta_1)$ ja $(G_2,\theta_2)$ the {\sl direct product} + $(G_1\times G_2,\theta_1\times\theta_2)$ as a group table. + (The binary operation in the product is $(x,y)\theta_1\times\theta_2 + (z,w) = (x\theta_1 z,y\theta_2 w)$). + +\bigskip + +\vfill\eject + +%========================================================================== +% Solutions to above sample exercises +%========================================================================== + +%\advance\vsize by 3truecm + +\choosett{apl} + +\noindent +\header%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\vskip 1cm + +\noindent +As the index of the neutral element we use the index origin \BX@IO@ which +usually has the value @0@. Then $S(N)= +\{0,\dots,N-1\}$, given by the vector \IO@N@. +An example on groups are the cyclic groups $({\bf Z}_n,+)$ +the group tables of which are generated by the \APL\ function @ZNPLUS@: + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL Z_ZNPLUS N;@BXIO +[1] @BXIO_0 +[2] Z_N@AB(@ION)@SO.+@ION + @DL +\endtt +}\smallskip + +\item{1.} The matrices represent binary operations of $S(N)$, + since they are $N\times N$-matrices with elements from + $S(N)$. They are all associative and also commutative except for + the case (b). This can be seen by the function @TEST@: + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL Z_TEST B +[1] " B IS A BINARY OPERATION. THE FUNCTION RETURNS A BOOLEAN 2-VECTOR +[2] " (B ASSOCIATIVE, B COMMUTATIVE) +[3] Z_(&/&/&/B[B;]=B[;B]),&/&/B=@TRB + @DL +\endtt +}\smallskip + +\item{2.} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL P_X GPOWER N;I +[1] " G GLOBAL +[2] P_@BXIO @DM I_0 +[3] TEST:@GO(N<I_I+1)/0 +[4] P_G[P;X] +[5] @GOTEST + @DL +\endtt +}\smallskip + +\item{3.} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL P_X BGPOWER N;IJ +[1] " G GLOBAL +[2] P_@BXIO +[3] NEXTJ:@GO(0=N,IJ_2@ABN)/0,SQX +[4] P_G[P;X] +[5] SQX:X_G[X;X] +[6] N_(N-IJ)%2 +[7] @GONEXTJ + @DL +\endtt +} + +\item{} A comment: if $i_j=0$, then the power is not increased, + but the square $x^{2^{j+1}}=(x^{2^j})^2$ is computed. + The number of iterations is $k$; $n = i_0+i_12+\cdots+i_k2^k \ge 2^k$, + when $i_k \not= 0$, and hence $k \le \log_2(n)$. + Thus, the complexity is $O(\log_2(n))$. +\smallskip + +\vfill\eject +\item{4.} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL Z_A GTSGP G +[1] " RETURNS THE SUBGROUP OF G GENERATED BY A +[2] Z_,A +[3] TEST:@GO(&/&/G[Z;Z]@EPZ)/FOUND +[4] Z_Z UNION G[Z;Z] +[5] @GOTEST +[6] FOUND:Z_Z[@GUZ] + @DL +\endtt +} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL Z_A UNION B;V;@BXIO +[1] V_(,A),,B +[2] @BXIO_1 +[3] Z_,CLEAN((@ROV),1)@ROV + @DL +\endtt +} + +The auxiliary function @CLEAN@ was given earlier. +\bigskip + +\item{5.} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL Z_INV G +[1] " RETURNS THE VECTOR OF INVERSE ELEMENTS OF G +[2] (@BXIO=,G)/,(@ROG)@ROG[@BXIO;] + @DL +\endtt +}\smallskip + +\item{6.} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL H_A BGTSGP G;Y +[1] " RETURNS THE SUBGROUP OF G GENERATED BY A +[2] H_Y_@BXIO +[3] B:@GO(0=@ROY_(,G[Y;A])MINUS H)/0 +[4] H_H UNION Y +[5] @GOB + @DL +\endtt +} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL Z_A MINUS B +[1] Z_(@NTA@EPB)/A + @DL +\endtt +}\smallskip + +\item{7.} If the elements of $G_i$ have been indexed by the interval + $[0,n_i-1]$, the elements of $G_1\times G_2$ become indexed + in a natural way by the elements of the Cartesian product + $[0,n_1-1]\times[0,n_2-1]$. With the bijection + $(i,j) \mapsto in_2+j:[0,n_1-1]\times[0,n_2-1] + \longrightarrow[0,n_1n_2-1]$ + (the inverse $k\mapsto((k-(k \bmod n_2))/n_2,k \bmod n_2)$ + selects the quotient and remainder in the division by $n_2$) + we get $[0,n_1n_2-1]$ as the index set. + +\vfill\eject +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL G_G1 PROD G2;@BXIO;I;J;IREM;JREM;N1;N2;N +[1] N_(N1_(@ROG1)[1])#N2_(@ROG2)[1] @DM I_@BXIO_0 +[2] G_(N,N)@RO0 +[3] JLOOP:J_0 +[4] CORE:G[I;J]_(G1[(I-IREM)%N2;(J-JREM)%N2]#N2)+G2[IREM_N2@ABI;JREM_N2@ABJ] +[5] @GO(N>J_J+1)/CORE +[6] @GO(N>I_I+1)/JLOOP + @DL +\endtt +} + +Example: + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + (ZNPLUS 2) PROD ZNPLUS 10 + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 + 1 2 3 4 5 6 7 8 9 0 11 12 13 14 15 16 17 18 19 10 + 2 3 4 5 6 7 8 9 0 1 12 13 14 15 16 17 18 19 10 11 + 3 4 5 6 7 8 9 0 1 2 13 14 15 16 17 18 19 10 11 12 + 4 5 6 7 8 9 0 1 2 3 14 15 16 17 18 19 10 11 12 13 + 5 6 7 8 9 0 1 2 3 4 15 16 17 18 19 10 11 12 13 14 + 6 7 8 9 0 1 2 3 4 5 16 17 18 19 10 11 12 13 14 15 + 7 8 9 0 1 2 3 4 5 6 17 18 19 10 11 12 13 14 15 16 + 8 9 0 1 2 3 4 5 6 7 18 19 10 11 12 13 14 15 16 17 + 9 0 1 2 3 4 5 6 7 8 19 10 11 12 13 14 15 16 17 18 +10 11 12 13 14 15 16 17 18 19 0 1 2 3 4 5 6 7 8 9 +11 12 13 14 15 16 17 18 19 10 1 2 3 4 5 6 7 8 9 0 +12 13 14 15 16 17 18 19 10 11 2 3 4 5 6 7 8 9 0 1 +13 14 15 16 17 18 19 10 11 12 3 4 5 6 7 8 9 0 1 2 +14 15 16 17 18 19 10 11 12 13 4 5 6 7 8 9 0 1 2 3 +15 16 17 18 19 10 11 12 13 14 5 6 7 8 9 0 1 2 3 4 +16 17 18 19 10 11 12 13 14 15 6 7 8 9 0 1 2 3 4 5 +17 18 19 10 11 12 13 14 15 16 7 8 9 0 1 2 3 4 5 6 +18 19 10 11 12 13 14 15 16 17 8 9 0 1 2 3 4 5 6 7 +19 10 11 12 13 14 15 16 17 18 9 0 1 2 3 4 5 6 7 8 +\endtt +} + +\end diff --git a/Master/texmf-dist/doc/latex/apl/sample.tex b/Master/texmf-dist/doc/latex/apl/sample.tex new file mode 100644 index 00000000000..85481d7c943 --- /dev/null +++ b/Master/texmf-dist/doc/latex/apl/sample.tex @@ -0,0 +1,124 @@ + +%============================================================================ +% S A M P L E . T E X +%============================================================================ + +%=================================================================== +% Sample problems; solutions give examples on using APL style in TeX +% Taken from the course ``Mathematics on the Computer'', Fall 87 +%=================================================================== + +\magnification = \magstep1 + +\advance\vsize by 3truecm + +\input mssymb % for some math symbols only! This is the new + % symbol font for some standard and non-standard + % mathematical symbols. It is only used here for + % blackboard bold letters. If you dont have it, + % just define \def\Bbb{} etc. + +\input aplstyle + +\choosett{apl} + +\font\sans = amss10 +\font\sltt = amsltt10 + +\def\header{{\sans Sample problems 9.\ 10.\ 1987}} +% some of them come from Sims' ``Abstract Algebra, A Computational Approach'' +\def\APL{{\sltt APL}} + +\nopagenumbers +\tolerance = 300 +\noindent +\header + +\vskip 2cm + +\item{1.} Let $N>1$ be an integer. Show that each of the following + matrices represents a binary operation on + $S(N)$ (we set locally \BX@IO_0@.) Which of them are + associative, which commutative? + \medskip + + \itemitem{a)} @(@\IO@N)@\SO@.@\CE\IO@N@ + + \itemitem{b)} \AB@(@\IO@N)@\SO@.-@\IO@N@ + + \itemitem{c)} @N@\AB@(@\IO@N)@\SO@.+@\IO@N@ + + \itemitem{d)} @N@\AB@(@\IO@N)@\SO@.#@\IO@N@ + + \medskip +\item{} Here @x@\CE@y@ is $\max(x,y)$, @x@\AB@y@ is + $y\bmod x$ and \AB@x@ is the absolute value of $x$. + +\bigskip + +\item{2.} Write an \APL\ function @GPOWER@ that computes for a group + @G@ (global variable) the $n$-th power of a given element $x$. + (If $S(M)$ is a representation vector of @G@, then + @GPOWER@ is a map $S(M)\times \Bbb Z\to S(M)$. Simply + use iteration.) + +\bigskip + +\item{3.} (Continuing problem 2.) A faster algorithm is obtained by + decomposing $x^n$ into its 2--base form + $x^n = x^{i_0}\times x^{2i_1}\times + x^{4i_2}\times ... \times x^{{2^k}i_k}$, where $i_j\in\{0,1\}$. Show + that the complexity of this algorithm is $O(\log_2(n))$. + (Show that the number of necessary multiplications does + not exceed $2\log_2(n)$). How would you write the corresponding + function in \APL? (Note that the binary representation of $n$ + can be obtained by applying iteratively the procedure $n\bmod 2$.) + +\bigskip + +\item{4.} Write an \APL\ function @GTSGP@ that computes for a given group @G@ + (global variable) the subgroup generated by a given subset $A$. The + function @GTSGP@ has one argument (the vector @A@) and returns + a subset of the set $S(N)$ (as a vector). (Extend the set @A@ + by the group operation until @A@ becomes closed with respect + to the operation.) + +\bigskip + +\item{5.} Write an \APL\ function @INV@ that returns for a group @G@ + the vector of inverse elements as a vector $S(N)\to S(N)$ so + that the index of the inverse of $x_i$ is @(INV G)[I]@. + +\bigskip + +\item{6.} Let $(G,\theta)$ be a group and let $A$ be a subset of $G$. Program + the following algorithm in \APL\ to find the subgroup @H@ + generated by @A@. Compare the perfomance of this algorithm + with the algorithm in Problem 4. + \medskip + + \itemitem{a)} put $H$ and $Y$ equal to $\{e\}$. + + \itemitem{b)} let $Y$ be $YA\smallsetminus H$. + + \itemitem{c)} if $Y=\emptyset$, stop. + + \itemitem{d)} put $H$ equal to $H\cup Y$ and + go to (b). + + \medskip +\item{} ($e$ is the neutral element and $YA\smallsetminus H$ + is the set--theoretical difference of $YA$ and $H$. + The product $YA$ is the set $\{y\theta a: y\in Y, a\in A\}$.) + +\bigskip + +\item{7.} Write an \APL\ function @PROD@ that returns for given groups + $(G_1,\theta_1)$ ja $(G_2,\theta_2)$ the {\sl direct product} + $(G_1\times G_2,\theta_1\times\theta_2)$ as a group table. + (The binary operation in the product is $(x,y)\theta_1\times\theta_2 + (z,w) = (x\theta_1 z,y\theta_2 w)$). + +\bigskip + +\vfill\eject diff --git a/Master/texmf-dist/doc/latex/apl/solutions.tex b/Master/texmf-dist/doc/latex/apl/solutions.tex new file mode 100644 index 00000000000..85e37305451 --- /dev/null +++ b/Master/texmf-dist/doc/latex/apl/solutions.tex @@ -0,0 +1,198 @@ + +%========================================================================== +% Solutions to above sample exercises +%========================================================================== + +%\advance\vsize by 3truecm + +\choosett{apl} + +\noindent +\header%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\vskip 1cm + +\noindent +As the index of the neutral element we use the index origin \BX@IO@ which +usually has the value @0@. Then $S(N)= +\{0,\dots,N-1\}$, given by the vector \IO@N@. +An example on groups are the cyclic groups $({\bf Z}_n,+)$ +the group tables of which are generated by the \APL\ function @ZNPLUS@: + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL Z_ZNPLUS N;@BXIO +[1] @BXIO_0 +[2] Z_N@AB(@ION)@SO.+@ION + @DL +\endtt +}\smallskip + +\item{1.} The matrices represent binary operations of $S(N)$, + since they are $N\times N$-matrices with elements from + $S(N)$. They are all associative and also commutative except for + the case (b). This can be seen by the function @TEST@: + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL Z_TEST B +[1] " B IS A BINARY OPERATION. THE FUNCTION RETURNS A BOOLEAN 2-VECTOR +[2] " (B ASSOCIATIVE, B COMMUTATIVE) +[3] Z_(&/&/&/B[B;]=B[;B]),&/&/B=@TRB + @DL +\endtt +}\smallskip + +\item{2.} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL P_X GPOWER N;I +[1] " G GLOBAL +[2] P_@BXIO @DM I_0 +[3] TEST:@GO(N<I_I+1)/0 +[4] P_G[P;X] +[5] @GOTEST + @DL +\endtt +}\smallskip + +\item{3.} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL P_X BGPOWER N;IJ +[1] " G GLOBAL +[2] P_@BXIO +[3] NEXTJ:@GO(0=N,IJ_2@ABN)/0,SQX +[4] P_G[P;X] +[5] SQX:X_G[X;X] +[6] N_(N-IJ)%2 +[7] @GONEXTJ + @DL +\endtt +} + +\item{} A comment: if $i_j=0$, then the power is not increased, + but the square $x^{2^{j+1}}=(x^{2^j})^2$ is computed. + The number of iterations is $k$; $n = i_0+i_12+\cdots+i_k2^k \ge 2^k$, + when $i_k \not= 0$, and hence $k \le \log_2(n)$. + Thus, the complexity is $O(\log_2(n))$. +\smallskip + +\vfill\eject +\item{4.} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL Z_A GTSGP G +[1] " RETURNS THE SUBGROUP OF G GENERATED BY A +[2] Z_,A +[3] TEST:@GO(&/&/G[Z;Z]@EPZ)/FOUND +[4] Z_Z UNION G[Z;Z] +[5] @GOTEST +[6] FOUND:Z_Z[@GUZ] + @DL +\endtt +} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL Z_A UNION B;V;@BXIO +[1] V_(,A),,B +[2] @BXIO_1 +[3] Z_,CLEAN((@ROV),1)@ROV + @DL +\endtt +} + +The auxiliary function @CLEAN@ was given earlier. +\bigskip + +\item{5.} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL Z_INV G +[1] " RETURNS THE VECTOR OF INVERSE ELEMENTS OF G +[2] (@BXIO=,G)/,(@ROG)@ROG[@BXIO;] + @DL +\endtt +}\smallskip + +\item{6.} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL H_A BGTSGP G;Y +[1] " RETURNS THE SUBGROUP OF G GENERATED BY A +[2] H_Y_@BXIO +[3] B:@GO(0=@ROY_(,G[Y;A])MINUS H)/0 +[4] H_H UNION Y +[5] @GOB + @DL +\endtt +} + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL Z_A MINUS B +[1] Z_(@NTA@EPB)/A + @DL +\endtt +}\smallskip + +\item{7.} If the elements of $G_i$ have been indexed by the interval + $[0,n_i-1]$, the elements of $G_1\times G_2$ become indexed + in a natural way by the elements of the Cartesian product + $[0,n_1-1]\times[0,n_2-1]$. With the bijection + $(i,j) \mapsto in_2+j:[0,n_1-1]\times[0,n_2-1] + \longrightarrow[0,n_1n_2-1]$ + (the inverse $k\mapsto((k-(k \bmod n_2))/n_2,k \bmod n_2)$ + selects the quotient and remainder in the division by $n_2$) + we get $[0,n_1n_2-1]$ as the index set. + +\vfill\eject +\hskip\parskip\vbox{\hsize=15truecm +\begintt + @DL G_G1 PROD G2;@BXIO;I;J;IREM;JREM;N1;N2;N +[1] N_(N1_(@ROG1)[1])#N2_(@ROG2)[1] @DM I_@BXIO_0 +[2] G_(N,N)@RO0 +[3] JLOOP:J_0 +[4] CORE:G[I;J]_(G1[(I-IREM)%N2;(J-JREM)%N2]#N2)+G2[IREM_N2@ABI;JREM_N2@ABJ] +[5] @GO(N>J_J+1)/CORE +[6] @GO(N>I_I+1)/JLOOP + @DL +\endtt +} + +Example: + +\hskip\parskip\vbox{\hsize=15truecm +\begintt + (ZNPLUS 2) PROD ZNPLUS 10 + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 + 1 2 3 4 5 6 7 8 9 0 11 12 13 14 15 16 17 18 19 10 + 2 3 4 5 6 7 8 9 0 1 12 13 14 15 16 17 18 19 10 11 + 3 4 5 6 7 8 9 0 1 2 13 14 15 16 17 18 19 10 11 12 + 4 5 6 7 8 9 0 1 2 3 14 15 16 17 18 19 10 11 12 13 + 5 6 7 8 9 0 1 2 3 4 15 16 17 18 19 10 11 12 13 14 + 6 7 8 9 0 1 2 3 4 5 16 17 18 19 10 11 12 13 14 15 + 7 8 9 0 1 2 3 4 5 6 17 18 19 10 11 12 13 14 15 16 + 8 9 0 1 2 3 4 5 6 7 18 19 10 11 12 13 14 15 16 17 + 9 0 1 2 3 4 5 6 7 8 19 10 11 12 13 14 15 16 17 18 +10 11 12 13 14 15 16 17 18 19 0 1 2 3 4 5 6 7 8 9 +11 12 13 14 15 16 17 18 19 10 1 2 3 4 5 6 7 8 9 0 +12 13 14 15 16 17 18 19 10 11 2 3 4 5 6 7 8 9 0 1 +13 14 15 16 17 18 19 10 11 12 3 4 5 6 7 8 9 0 1 2 +14 15 16 17 18 19 10 11 12 13 4 5 6 7 8 9 0 1 2 3 +15 16 17 18 19 10 11 12 13 14 5 6 7 8 9 0 1 2 3 4 +16 17 18 19 10 11 12 13 14 15 6 7 8 9 0 1 2 3 4 5 +17 18 19 10 11 12 13 14 15 16 7 8 9 0 1 2 3 4 5 6 +18 19 10 11 12 13 14 15 16 17 8 9 0 1 2 3 4 5 6 7 +19 10 11 12 13 14 15 16 17 18 9 0 1 2 3 4 5 6 7 8 +\endtt +} + +\end + + diff --git a/Master/texmf-dist/doc/latex/apl/tugboat.tex b/Master/texmf-dist/doc/latex/apl/tugboat.tex new file mode 100644 index 00000000000..87b1461a1cc --- /dev/null +++ b/Master/texmf-dist/doc/latex/apl/tugboat.tex @@ -0,0 +1,530 @@ + +%============================================================================= +% T U G B O A T . T E X +%============================================================================= +%======================================================================== +% A TeX file for the paper on APL-TeX (new version, not published) +% +% A.Hohti/O.Kanerva (University of Helsinki) April 1987 +%======================================================================== +% +% +% Version of August 26, 1987 at 15:00 +% +% +%======================================================================== +\input aplstyle % the file containing the APL definitions +%======================================================================== +% +% +\magnification=\magstep1 % for weak eyes! +% +% +%======================================================================== +\font\bigbf=ambx10 % for titles +\font\sltt=amsltt10 % for file contents inside text +\font\manual=manfnt at 10pt % for major METAFONT logo +\font\minual=manfnt at 9pt % for minor METAFONT logo +\input ninesize % abstract, references +%======================================================================== +% +\def\METAFONT{{\manual META}\-{\manual FONT}} +\def\metafont{{\minual META}\-{\minual FONT}} +% +%======================================================================== +% stylistic definitions +\def\section#1{\vskip0pt plus .1\vsize + \penalty-250\vskip0pt plus-.1\vsize\bigskip + \noindent{\bf #1.\ }\nobreak\message{#1}} +\def\abstract#1{\bigskip\centerline{\hbox{ + \vbox{\hsize=4.75truein{\ninepoint \noindent ABSTRACT.\enspace#1}}}}} +\def\APL{{\sl APL}} +% this definition is from the TeXbook, Ex. 21.3 : +\def\boxit#1{\vbox{\hrule \hbox{\vrule \kern2pt + \vbox{\kern2pt#1\kern2pt}\kern2pt\vrule}\hrule}} +% A macro for making references and blocks. +% +\newdimen\refindent\newdimen\plusindent +\newdimen\refskip\newdimen\tempindent +\newdimen\extraindent +\newcount\refcount +% +% \refskip has to be set by the user! Otherwise \parindent is +% used, in accordance with \item. +% +\refcount=0 +\def\ref#1:#2.-#3\par{\ninepoint % switch to nine point fonts +\advance\refcount by 1 +\setbox0=\hbox{[\number\refcount]}\refindent=\wd0 +\plusindent=\refskip\extraindent=\refskip +\advance\plusindent by -\refindent\tempindent=\parindent % +\parindent=0pt\par\hangindent\extraindent % + [\number\refcount]\hskip\plusindent #1:{\sl#2},#3 +\parindent=\tempindent} +% +\refskip=\parindent +% +%======================================================================== + % HEADER +\null +\vskip2truecm +% + \centerline{\bigbf GENERATING AN \APL\ FONT} +% +\vskip.75truecm +% + \centerline{\sl Aarno Hohti and Okko Kanerva} +% +\vskip.5truecm +% + \centerline{\sl University of Helsinki} +\vskip.5truecm +\abstract{The \APL\ language is well known for its peculiar + symbols which have inhibited the use of this language + in many programming environments. Making \APL\ + documents of good quality has been difficult and + expensive. We describe here a simple way how to + use \metafont\ to generate an \APL\ font for \TeX\ + by using existing font definitions as far as possible.} +\vskip.5truecm +%======================================================================== +% +\section{Introduction} +This note describes an interesting exercise in using +\METAFONT\ to produce new typefaces by combining letters +from standard fonts. As we know, the \APL\ language [6] of +Kenneth Iverson has never gained the popularity it deserves +which is largely due to its strange symbol set. Indeed, +true \APL\ users require a special keyboard to support +the nonstandard but powerful operator symbols. Moreover, +putting \APL\ into print has always been a problem, and +modern low cost computerized typesetting programs do +not usually support \APL\ style. \TeX\ can be used to +produce high quality printouts for technical text, +and it would be desirable to have a possibility to +mix in \APL\ code. The companion program of +\TeX ---\METAFONT ---provides a full means for a simple generation +of an \APL\ font for \TeX, and the purpose of this +note is to inform other people about the result we +have obtained at the University of Helsinki. Let us note +that there are at least three other \APL\ fonts available +for small computer environments. Indeed, the newsletter +\APL\ {\it Quote Quad\/}\footnote{*}{{\ninepoint Newsletter of SIGAPL, +the Special Interest Group for \APL. {\it Quote Quad\/} has the same +status in the world of \APL\ as TUGboat in \TeX{nical} world.}} +is produced by using TROFF, and there +exists a Postscript \APL\ font for the Apple Laserwriter [5] and +another font for the TEXT typesetting system [2]. + +Consider the following usual kind of function definition in \APL: +\choosett{apl} +\begintt + @DLS_SUMSQ N;I + [1] S_I_0 + [2] @GO(N<I_I+1)/0 + [3] S_S+I*2 + [4] @GO2 + [5] @DL +\endtt +\choosett{sltt}% %@@@@ +How to write in this code, providing that we have a suitable +font? The \APL\ font should represent the screen +output style of \APL\ code and obey the same laws of spacing. +Hence, it should be a typewriter-like typeface with fixed +spacing; the same approach for representing \TeX\ input was +adopted by Knuth in the {\TeX}book. +The {\it verbatim\/} macros have often been used for importing +screen or paper outputs into \TeX\ documents; some people +misuse them for an easy construction of tables etc. In +{\sltt verbatim}, the typewriter mode is entered by the control +sequence @\begintt@---that mode is ended by +@\endtt@. In the same vein, we could enter +the \APL\ mode by the control sequence @\beginapl@, +and to end it by @\endapl@. However, it is more convenient to +augment {\sltt verbatim\/} with {\sltt aplstyle\/} so that +it can be used with several different typewriter-like fonts. +(The {\it verbatim\/} macros can be found in the {\TeX}book, +p.\ 421.) Since {\sltt\char'100\/} +(the {\it at sign}) is used as the escape character inside {\it verbatim\/} +mode, our \TeX\ code might (and in fact does) look as follows: +\def\endsym{\char'134{endtt}} % just for using \endtt after \begintt + % without actually ending anything +\choosett{tentt} +\begintt + \choosett{apl} + \begintt + @@DLS_SUMSQ N;I + [1] S_I_0 + [2] @@GO(N<I_I+1)/0 + [3] S_S+I*2 + [4] @@GO2 + [5] @@DL + @endsym +\endtt +\choosett{sltt}% %@@@@ +The control sequences @\DL@ and @\GO@ are not chosen arbitrarily +but follow the conventions used in Digital's VAX \APL\ interpreter [1]. +As terminals usually do not support the \APL\ character set, an +alternative representation by two-letter mnemonics is provided by the +interpreter. For the most part we have adopted these mnemonics also for our +\APL\ font. Hence, as an additional bonus the user should find it +easy to combine his or her \APL\ code with normal \TeX\ code. Thus, +it is not necessary for a VAX \APL\ user to retype the definitions +of \APL\ functions in order to be able to use them in documents. +He or she only has to replace every {\it period\/} used as an +escape character in Digital's interpreter, by {\sltt\char'100}. +(There is another syntactical difference between Digital's interpreter +and \TeX's {\it verbatim\/} mode: for the interpreter +the third ordinary character after an escape character +does no longer belong to the escape sequence while \TeX\ admits +arbitrarily long control sequences. We take care of this +by changing certain {\it catcodes\/} temporarily.) +% +% +\choosett{apl}% +% +\section{The \APL\ font table} +\APL\ symbols are divided into two classes: the primitive symbols +and those obtained by overstriking two primitive ones. The overstrikes +are traditionally obtained by typing the first symbol, by using +backspace to go back one space and then typing the second symbol +{\sl over\/} the first one. However, in modern \APL\ keyboards these +double symbols are assigned to non-alphanumeric keys (for example, +to keys under the {\sltt ALT\/} key). We decided to include only the +primitive \APL\ symbols in the font table; this enabled us to include +also the lower-case letters, following modern conventions. (The original +\APL\ letters were restricted to capitals.) The comment symbol +@"@ is the only exception since it is keyed in as a double quote. +Our font is a fixed size typeface with strongly slanted letters. +Moreover, we have followed the style of best books in \APL: +all symbols should be drawn with a thin pen to get a touch of +a typewriter. (This point is clearly witnessed, for example, in [5].) +The places of some symbols are determined by the \TeX\ font tables. +For example, the hash sign {\sltt\char'043\/} is used for the +multiplication sign in VAX \APL, and hence the corresponding symbol +has the the same octal code (043) as the hash sign in \TeX. +The font table has the following form: %@@@@ + +%======================================================================== +% table begins +%======================================================================== +% This macro comes from TUGboat (I (AH) do not remember which number), +% unsuitable parts are commented out. +% +{\baselineskip=0pt \lineskip=0pt +\newdimen\vu +% +%\output={\shipout\vbox{\unvbox255\vskip0.4in}\advancepageno} +% +\setbox9=\hbox{\sl 0} +\def\spike{\hbox to 0pt{\vbox to \ht9{}}} +\def\cell#1{\hbox to 1\vu{\hfill\char'#1\hfill}\vrule} +\def\label#1{\vbox to \ht8{\vfill\hbox to 35pt{\hfill\sl '#10\hskip1em% + }\vfill}\vrule} +% +\def\seprow{\def\m{\hskip 1\vu{}\vrule height 2pt}\hbox{\m\m\m\m\m\m\m\m}} +\def\cellrow#1{\setbox8=\vbox{\seprow\hbox{\spike% + \cell{#10}\cell{#11}\cell{#12}\cell{#13}% + \cell{#14}\cell{#15}\cell{#16}\cell{#17}\hfill% + }\seprow\hrule}\hbox{\label{#1}\box8}} +% +\def\lcol#1{\hbox to 1\vu{\hfill{\sl #1}\hfill}\hskip .4pt} +\def\chw#1{\hbox{\char'#1}} +% +\def\colw#1{\vbox{\chw{#10} + \chw{#11} + \chw{#12} + \chw{#13} + \chw{#14} + \chw{#15} + \chw{#16} + \chw{#17}}} +% +\def\setw#1{\vbox{\colw{#10} + \colw{#11} + \colw{#12} + \colw{#13} + \colw{#14} + \colw{#15} + \colw{#16} + \colw{#17}}} +% +\def\getw{\setbox0=\vbox{\setw0\setw1\hbox to \wd9{}\hbox to 1em{}}% + \vu=1.625\wd0} +% + \apl\getw\bigskip % changed from \null\vfill to \bigskip +% + \centerline{\vbox{%\hbox{\hskip35pt{\sl cmapl10}\hfill} +% \vskip20pt + \hbox{\hskip35pt\lcol0\lcol1\lcol2\lcol3\lcol4\lcol5\lcol6\lcol7} + \vskip 4pt + \hbox{\hskip35pt\vbox{\hrule width 8\vu}\vbox{\hrule width 3.6pt}} + \cellrow{00}\cellrow{01}\cellrow{02}\cellrow{03} + \cellrow{04}\cellrow{05}\cellrow{06}\cellrow{07} + \cellrow{10}\cellrow{11}\cellrow{12}\cellrow{13} + \cellrow{14}\cellrow{15}\cellrow{16}\cellrow{17}}}} % removed \vfill +% % from the end +% +%======================================================================== +% table ends +%======================================================================== +% +\section{The necessary \METAFONT\ files} +The whole process started when the first author had a paper +containing \APL\ symbols and was disappointed with the +quality of the symbols available on the typewriter. Moreover, +the secretary who had typed the text had forgot a couple +of lines in the middle of the paper, and the correction of +such mistakes seemed to be very clumsy in comparison with +modern typesetting. Then he decided (together with the second +author) to remedy the situation by creating an \APL\ font for +\TeX\ he was using for other kinds of document. Many of the +\APL\ symbols needed were contained in standard fonts; for example, +{\it diamond\/} can be found in {\it cmsy10}. For alphanumeric +characters one could use {\it cmsltt10}. The simplest try for +a solution of the problem would be to write a list of definitions +that pick symbols from appropriate fonts. However, this brute force +method does not really work since these symbols come from +very different typefaces and, moreover, do not provide a fixed +typeface. Hence, we decided to find an easy way of producing +an \APL\ font by using \METAFONT. + +As the starting point, we took the font {\it cmtex10}. This is a +fixed typeface for an extended typewriter-like font including +some Greek characters and mathematical symbols. The \METAFONT\ file +for this font, {\sltt cmtex10.mf\/} contains (as usual) a preamble +that assigns values to several global variables, and the command +{\sltt generate textset;\/}. Now the {\sl driver\/} file {\sltt textset.mf\/} %@@@@ +contains the commands {\sltt mode\_setup;font\_setup;\/} %@@@@ +(establishing the values of the variables for this font) and several +input files from which the \METAFONT\ descriptions of the characters are to +be found. Since some of these files treat the characters by name and +since some of the definitions have to be changed (and some dropped), +we considered it advisable to discard the driver file and to collect +the separate \METAFONT\ files, together with the preamble, to form a +large single file {\sltt cmapl10.mf}. The {\sltt .mf\/} character files +needed for {\sltt cmapl10.mf\/} are the following: +% +% +$$\vbox{\halign{{\sltt#}\hfil && \quad #\hfil\cr +% + greekl & ({\it rho, omega, alpha}) \cr + italms & ({\it iota}) \cr + romand & (roman digits) \cr + punct & (punctuation symbols) \cr + romanp & \cr + symbol & (math symbols) \cr + sym & \cr + romanu & (uppercase letters) \cr + romanl & (lowercase letters) \cr +% +}}$$ +% +% +\section{Definitions} +\choosett{tentt}% +The first thing to do is to put {\sltt font\_identifier:="CMAPL";\/} %@@@@ +and to set {\sltt slant:=0;\/} in the preamble. Many definitions can %@@@@ +be copied verbatim from the {\sltt .mf\/} files, but some of them +need changes. The Greek {\it iota}, as given in {\sltt greekl.mf}, +is strange to \APL\ style; we use instead the {\it dotless i\/} +from {\sltt italms.mf}. Moreover, we used the symbol {\it elt\/} +(element) from {\sltt sym.mf\/} instead of the Greek {\it epsilon}. +The symbols {\it del\/} and {\it delta\/} are +taken from {\sltt symbol.mf\/} (where their names are {\it large triangle\/} +and {\it large inverted triangle}). However, they are too sturdy +and too short to be placed in a proper \APL\ font. Further, {\it del\/} +must be lifted up so that it is vertically aligned with other +symbols. The modifications are very easy to do, and the modified %@@@@ , by ,and +definition is shown below. +% +% +\choosett{tentt} +\begintt + % sqrt48 was changed to 6.25 since the del symbol in APL has + % a narrower top than the original reversed triangle symbol + % rule.nib has been changed to light_rule.nib + % bot y3=-d-o has been changed to bot y3=0 + % top y1=h-d has been changed to top y1=h+2o + @null + cmchar "Del"; + beginchar(oct"002",16u#,asc_height#,0); + adjust_fit(0,0); pickup light_rule.nib; + top y1=h+2o; y2=y1; bot y3=0; + .5[x1,x2]=x3=good.x .5w; w:=r:=2x3; lft x1=hround(.5w-u*6.25); + draw z1--z2--z3--cycle; % stroke + labels(1,2,3); endchar; +\endtt +As can be seen from this example, pen strokes were made thinner. +Actually only one symbol was directly missing---this is the {\it quad +box}. However, it can be obtained from the above by adding one control point: +\begintt + cmchar "Quad"; + beginchar(oct"001",16u#,body_height#,0); + adjust_fit(0,0); pickup light_rule.nib; + bot y1=0; y2=y1; top y3=h+2o; y4=y3; + .5[x1,x2]=x5=good.x .5w; w:=r:=2x5; + % The quad box is slightly wider than Del + lft x1=hround(.5w-u*7); + x3=x1; x4=x2; + draw z1--z2--z4--z3--cycle; % box + labels(1,2,3,4); endchar; +\endtt +After taking care of special symbols, the letters can be treated +by finding a suitable value for {\it tilt ratio\/} (slant). Indeed, +\APL\ letters are {\sl very\/} slanted. We suggest the value +1/5 for this font (the font {\it cmsl10\/} uses 1/6). One should +remember to give the command {\sltt font\_setup;\/} after setting {\sltt slant\/} %@@@@ +to 1/5. +\choosett{sltt}% %@@@@ +Finally, one has to make the {\it verbatim\/} macros +suitable for \APL\ style. Since {\it verbatim\/} might be +used for several different fonts in one document, we decided +to include a control sequence @\choosett@. +\choosett{tentt} +\begintt + \def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax} + \newif\ifapl \def\aplname{apl} + \outer\def\choosett#1{\ifundefined{#1}% + \message{Undefined font(?), replaced with cmtt10}% + \let\tt=\tentt + \else + \def\tt{\expandafter\csname#1\endcsname}% + \def\ttname{#1}% + \ifx\ttname\aplname\apltrue\else\aplfalse\fi\fi} +\endtt +\choosett{sltt}% +(The control sequence @\ifundefined@ comes from the \TeX{book}, p.\ 308.) +With the help of @\choosett@, the standard @verbatim@ macros can be used +with the single change that @\ifapl@, then the @\catcode@ of @A@,\dots,@Z@ +is @\other@ (12) instead of 11 for {\it letter}. Under \APL\ mode \TeX\ +will then recognize our single-letter control sequences defined, e.g., by +\choosett{tentt} +\begintt + \def\A#1{\if#1B{\apl\char'174}\else % stile + \if#1M{\apl\char'004}\fi\fi} % alpha . +\endtt +\choosett{sltt}% +Unfortunately, we have redefined the standard @\L@, @\O@, @\P@ and @\S@. + +The \APL\ symbols not in the font table are obtained---as usual---by +overstriking two table symbols. +\choosett{tentt}% +\begintt + \newbox\firstchar\newskip\charwidth + \def\overstrike#1#2{\setbox\firstchar=\hbox{#1}\charwidth=\wd\firstchar + #1\hskip-\charwidth#2} +\endtt +\choosett{apl}% +For example, the {\it grade up\/} and {\it grade down\/} symbols +\G U\ and \G D\ are obtained by striking the {\it stile\/} symbol +@|@ over \L D\ and \D L, respectively. +\choosett{tentt}% +\begintt + \def\G#1{\if#1U{\overstrike{\LD}{\AB}}\else % grade up + \if#1D{\overstrike{\DL}{\AB}}\fi\fi} % grade down +\endtt +Now let us take another example on \APL. The input +\begintt + \choosett{apl} % in case some other choice is in force + \setbox0=\vbox{\hsize=5.7truein + \begintt + [0] Z_A1 PROD A2;A;I;V + [1] "RETURNS THE PRODUCT OF THE POLYNOMIALS A1 AND A2 + [2] "THE ARGUMENTS ARE GIVEN AS COEFFICIENT ARRAYS + [3] I_@@ROA1 + [4] Z_A1@@SO.#A2 + [5] LOOP:V_@@ROZ @@DM V[(@@ROI)+1]_V[1] + [6] V_@@ROZ_Z,[(@@ROI)+1]V@@RO0 + [7] A_(1+-@@IOV[1])@@SO.#((@@NT(@@IO@@ROV)@@EP(1,(@@ROI)+1))/V)@@RO1 + [8] Z_+/[1]A@@RV[(@@ROI)+1]Z + [9] ((@@RO@@ROZ)>@@ROI)/LOOP + @endsym + } + $$\boxit{\boxit{\box0}}$$ + \centerline{\sevenrm An APL function for polynomial multiplication} +\endtt +% +gives the output +% +\choosett{apl} +\setbox0=\vbox{\hsize=5.7truein +\begintt + [0] Z_A1 PROD A2;A;I;V + [1] "RETURNS THE PRODUCT OF THE POLYNOMIALS A1 AND A2 + [2] "THE ARGUMENTS ARE GIVEN AS COEFFICIENT ARRAYS + [3] I_@ROA1 + [4] Z_A1@SO.#A2 + [5] LOOP:V_@ROZ @DM V[(@ROI)+1]_V[1] + [6] V_@ROZ_Z,[(@ROI)+1]V@RO0 + [7] A_(1+-@IOV[1])@SO.#((@NT(@IO@ROV)@EP(1,(@ROI)+1))/V)@RO1 + [8] Z_+/[1]A@RV[(@ROI)+1]Z + [9] ((@RO@ROZ)>@ROI)/LOOP +\endtt + } +$$\boxit{\boxit{\box0}}$$ +\centerline{\sevenrm An APL function for polynomial multiplication} +% +\section{User extension} +A modern user of a computerized typesetting facility will probably +ask if it is possible to extend or modify fonts coming with the +system. As with [5], where the font has an {\it analytic\/} and a +{\it bitmapped\/} variant, we can distinguish between the need of modifying +{\it cmapl10\/} via \METAFONT\ and modification of the pixel files. +\APL\ symbols of various ``blackness'' or ``thickness'' may be desirable. +Indeed, in [3] the user input is written with boldface \APL\ symbols +and the answers from the interpreter with thin ones. Furthermore, +certain screen previewers use specific small size pixel files, and +do not support the \APL\ font. + +The modification of the font by changing the values of some global +variables in the preamble of the \METAFONT\ file is easy and can be +done by following how it is done in standard fonts such as +{\it cmbx10\/} etc. This is the recommended way, too. However, if +\METAFONT\ is not available, then one must attack the pixel files. +For direct hand editing, we use a program that converts a pixel +file into a (bitmapped) text file acceptable to any standard screen +editor, and another program reading the edited file back into +a \TeX\ pixel file. Scaling fonts down to a desired size can be +done in a similar (but automatic) manner; this facility is needed +by a previewer (written by the first author) not using runtime +scaling. + + +\section{References} +\bigskip +{ +\ref Digital Equipment Corporation: VAX-11 \APL\ Reference Manual.- + 1983. + +\ref Feldberg, Ian: TEXT: Publication-Quality Characters Come + to \APL\ Graphics.- Proceedings of the 1986 \APL\ Conference, + SIGAPL, pp.\ 306--313. + +\ref Gilman, Leonard, and Allen J.\ Rose: \APL, An Interactive + Approach.- John Wiley \& Sons, Inc., 1984. + +\ref Grenander, Ulf: Mathematical Experiments on the Computer.- + Academic Press, 1982. + +\ref Howland, John E.: Typesetting \APL\ Using a Macintosh.- + Proceedings of the 1986 \APL\ Conference, SIGAPL, pp.\ 301--305. + +\ref Iverson, Kenneth: A Programming Language.- Wiley, New York, 1962. + + + } + +\bigskip +\section{The address} +\bigskip +{\ninepoint\obeylines +\hskip\refskip University of Helsinki +\hskip\refskip Department of Mathematics +\hskip\refskip Hallituskatu 15 +\hskip\refskip SF--00100 HELSINKI +\hskip\refskip FINLAND +} + +\end + diff --git a/Master/texmf-dist/doc/latex/apl/tugboat2.tex b/Master/texmf-dist/doc/latex/apl/tugboat2.tex new file mode 100644 index 00000000000..05a6398b724 --- /dev/null +++ b/Master/texmf-dist/doc/latex/apl/tugboat2.tex @@ -0,0 +1,534 @@ + +%============================================================================= +% T U G B O A T . T E X +%============================================================================= +%======================================================================== +% A TeX file for the paper on APL-TeX (new version, not published) +% +% A.Hohti/O.Kanerva (University of Helsinki) April 1987 +%======================================================================== +% +% +% Version of August 26, 1987 at 15:00 +% +% +%======================================================================== +\input aplstyle % the file containing the APL definitions +%======================================================================== +% +% +\magnification=\magstep1 % for weak eyes! +% +% +%======================================================================== +\font\bigbf=ambx10 % for titles +\font\sltt=amsltt10 % for file contents inside text +\font\manual=manfnt at 10pt % for major METAFONT logo +\font\minual=manfnt at 9pt % for minor METAFONT logo +\input ninesize % abstract, references +%======================================================================== +% +\def\METAFONT{{\manual META}\-{\manual FONT}} +\def\metafont{{\minual META}\-{\minual FONT}} +% +%======================================================================== +% stylistic definitions +\def\section#1{\vskip0pt plus .1\vsize + \penalty-250\vskip0pt plus-.1\vsize\bigskip + \noindent{\bf #1.\ }\nobreak\message{#1}} +\def\abstract#1{\bigskip\centerline{\hbox{ + \vbox{\hsize=4.75truein{\ninepoint \noindent ABSTRACT.\enspace#1}}}}} +\def\APL{{\sl APL}} +% this definition is from the TeXbook, Ex. 21.3 : +\def\boxit#1{\vbox{\hrule \hbox{\vrule \kern2pt + \vbox{\kern2pt#1\kern2pt}\kern2pt\vrule}\hrule}} +% A macro for making references and blocks. +% +\newdimen\refindent\newdimen\plusindent +\newdimen\refskip\newdimen\tempindent +\newdimen\extraindent +\newcount\refcount +% +% \refskip has to be set by the user! Otherwise \parindent is +% used, in accordance with \item. +% +\refcount=0 +\def\ref#1:#2.-#3\par{\ninepoint % switch to nine point fonts +\advance\refcount by 1 +\setbox0=\hbox{[\number\refcount]}\refindent=\wd0 +\plusindent=\refskip\extraindent=\refskip +\advance\plusindent by -\refindent\tempindent=\parindent % +\parindent=0pt\par\hangindent\extraindent % + [\number\refcount]\hskip\plusindent #1:{\sl#2},#3 +\parindent=\tempindent} +% +\refskip=\parindent +% +%======================================================================== + % HEADER +\null +\vskip2truecm +% + \centerline{\bigbf GENERATING AN \APL\ FONT} +% +\vskip.75truecm +% + \centerline{\sl Aarno Hohti and Okko Kanerva} +% +\vskip.5truecm +% + \centerline{\sl University of Helsinki} +\vskip.5truecm +\abstract{The \APL\ language is well known for its peculiar + symbols which have inhibited the use of this language + in many programming environments. Making \APL\ + documents of good quality has been difficult and + expensive. We describe here a simple way how to + use \metafont\ to generate an \APL\ font for \TeX\ + by using existing font definitions as far as possible.} +\vskip.5truecm +%======================================================================== +% +\section{Introduction} +This note describes an interesting exercise in using +\METAFONT\ to produce new typefaces by combining letters +from standard fonts. As we know, the \APL\ language [6] of +Kenneth Iverson has never gained the popularity it deserves +which is largely due to its strange symbol set. Indeed, +true \APL\ users require a special keyboard to support +the nonstandard but powerful operator symbols. Moreover, +putting \APL\ into print has always been a problem, and +modern low cost computerized typesetting programs do +not usually support \APL\ style. \TeX\ can be used to +produce high quality printouts for technical text, +and it would be desirable to have a possibility to +mix in \APL\ code. The companion program of +\TeX ---\METAFONT ---provides a full means for a simple generation +of an \APL\ font for \TeX, and the purpose of this +note is to inform other people about the result we +have obtained at the University of Helsinki. Let us note +that there are at least three other \APL\ fonts available +for small computer environments. Indeed, the newsletter +\APL\ {\it Quote Quad\/}\footnote{*}{{\ninepoint Newsletter of SIGAPL, +the Special Interest Group for \APL. {\it Quote Quad\/} has the same +status in the world of \APL\ as TUGboat in \TeX{nical} world.}} +is produced by using TROFF, and there +exists a Postscript \APL\ font for the Apple Laserwriter [5] and +another font for the TEXT typesetting system [2]. + +Consider the following usual kind of function definition in \APL: +\choosett{apl} +\begintt + @DLS_SUMSQ N;I + [1] S_I_0 + [2] @GO(N<I_I+1)/0 + [3] S_S+I*2 + [4] @GO2 + [5] @DL +\endtt +\choosett{sltt}% %@@@@ +How to write in this code, providing that we have a suitable +font? The \APL\ font should represent the screen +output style of \APL\ code and obey the same laws of spacing. +Hence, it should be a typewriter-like typeface with fixed +spacing; the same approach for representing \TeX\ input was +adopted by Knuth in the {\TeX}book. +The {\it verbatim\/} macros have often been used for importing +screen or paper outputs into \TeX\ documents; some people +misuse them for an easy construction of tables etc. In +{\sltt verbatim}, the typewriter mode is entered by the control +sequence @\begintt@---that mode is ended by +@\endtt@. In the same vein, we could enter +the \APL\ mode by the control sequence @\beginapl@, +and to end it by @\endapl@. However, it is more convenient to +augment {\sltt verbatim\/} with {\sltt aplstyle\/} so that +it can be used with several different typewriter-like fonts. +(The {\it verbatim\/} macros can be found in the {\TeX}book, +p.\ 421.) Since {\sltt\char'100\/} +(the {\it at sign}) is used as the escape character inside {\it verbatim\/} +mode, our \TeX\ code might (and in fact does) look as follows: +\def\endsym{\char'134{endtt}} % just for using \endtt after \begintt + % without actually ending anything +\choosett{tentt} +\begintt + \choosett{apl} + \begintt + @@DLS_SUMSQ N;I + [1] S_I_0 + [2] @@GO(N<I_I+1)/0 + [3] S_S+I*2 + [4] @@GO2 + [5] @@DL + @endsym +\endtt +\choosett{sltt}% %@@@@ +The control sequences @\DL@ and @\GO@ are not chosen arbitrarily +but follow the conventions used in Digital's VAX \APL\ interpreter [1]. +As terminals usually do not support the \APL\ character set, an +alternative representation by two-letter mnemonics is provided by the +interpreter. For the most part we have adopted these mnemonics also for our +\APL\ font. Hence, as an additional bonus the user should find it +easy to combine his or her \APL\ code with normal \TeX\ code. Thus, +it is not necessary for a VAX \APL\ user to retype the definitions +of \APL\ functions in order to be able to use them in documents. +He or she only has to replace every {\it period\/} used as an +escape character in Digital's interpreter, by {\sltt\char'100}. +(There is another syntactical difference between Digital's interpreter +and \TeX's {\it verbatim\/} mode: for the interpreter +the third ordinary character after an escape character +does no longer belong to the escape sequence while \TeX\ admits +arbitrarily long control sequences. We take care of this +by changing certain {\it catcodes\/} temporarily.) +% +% +\choosett{apl}% +% +\section{The \APL\ font table} +\APL\ symbols are divided into two classes: the primitive symbols +and those obtained by overstriking two primitive ones. The overstrikes +are traditionally obtained by typing the first symbol, by using +backspace to go back one space and then typing the second symbol +{\sl over\/} the first one. However, in modern \APL\ keyboards these +double symbols are assigned to non-alphanumeric keys (for example, +to keys under the {\sltt ALT\/} key). We decided to include only the +primitive \APL\ symbols in the font table; this enabled us to include +also the lower-case letters, following modern conventions. (The original +\APL\ letters were restricted to capitals.) The comment symbol +@"@ is the only exception since it is keyed in as a double quote. +Our font is a fixed size typeface with strongly slanted letters. +Moreover, we have followed the style of best books in \APL: +all symbols should be drawn with a thin pen to get a touch of +a typewriter. (This point is clearly witnessed, for example, in [5].) +The places of some symbols are determined by the \TeX\ font tables. +For example, the hash sign {\sltt\char'043\/} is used for the +multiplication sign in VAX \APL, and hence the corresponding symbol +has the the same octal code (043) as the hash sign in \TeX. +The font table has the following form: %@@@@ + +%======================================================================== +% table begins +%======================================================================== +% This macro comes from TUGboat (I (AH) do not remember which number), +% unsuitable parts are commented out. +% +{\baselineskip=0pt \lineskip=0pt +\newdimen\vu +% +%\output={\shipout\vbox{\unvbox255\vskip0.4in}\advancepageno} +% +\setbox9=\hbox{\sl 0} +\def\spike{\hbox to 0pt{\vbox to \ht9{}}} +\def\cell#1{\hbox to 1\vu{\hfill\char'#1\hfill}\vrule} +\def\label#1{\vbox to \ht8{\vfill\hbox to 35pt{\hfill\sl '#10\hskip1em% + }\vfill}\vrule} +% +\def\seprow{\def\m{\hskip 1\vu{}\vrule height 2pt}\hbox{\m\m\m\m\m\m\m\m}} +\def\cellrow#1{\setbox8=\vbox{\seprow\hbox{\spike% + \cell{#10}\cell{#11}\cell{#12}\cell{#13}% + \cell{#14}\cell{#15}\cell{#16}\cell{#17}\hfill% + }\seprow\hrule}\hbox{\label{#1}\box8}} +% +\def\lcol#1{\hbox to 1\vu{\hfill{\sl #1}\hfill}\hskip .4pt} +\def\chw#1{\hbox{\char'#1}} +% +\def\colw#1{\vbox{\chw{#10} + \chw{#11} + \chw{#12} + \chw{#13} + \chw{#14} + \chw{#15} + \chw{#16} + \chw{#17}}} +% +\def\setw#1{\vbox{\colw{#10} + \colw{#11} + \colw{#12} + \colw{#13} + \colw{#14} + \colw{#15} + \colw{#16} + \colw{#17}}} +% +\def\getw{\setbox0=\vbox{\setw0\setw1\hbox to \wd9{}\hbox to 1em{}}% + \vu=1.625\wd0} +% + \apl\getw\bigskip % changed from \null\vfill to \bigskip +% + \centerline{\vbox{%\hbox{\hskip35pt{\sl cmapl10}\hfill} +% \vskip20pt + \hbox{\hskip35pt\lcol0\lcol1\lcol2\lcol3\lcol4\lcol5\lcol6\lcol7} + \vskip 4pt + \hbox{\hskip35pt\vbox{\hrule width 8\vu}\vbox{\hrule width 3.6pt}} + \cellrow{00}\cellrow{01}\cellrow{02}\cellrow{03} + \cellrow{04}\cellrow{05}\cellrow{06}\cellrow{07} + \cellrow{10}\cellrow{11}\cellrow{12}\cellrow{13} + \cellrow{14}\cellrow{15}\cellrow{16}\cellrow{17}}}} % removed \vfill +% % from the end +% +%======================================================================== +% table ends +%======================================================================== +% +\section{The necessary \METAFONT\ files} +The whole process started when the first author had a paper +containing \APL\ symbols and was disappointed with the +quality of the symbols available on the typewriter. Moreover, +the secretary who had typed the text had forgot a couple +of lines in the middle of the paper, and the correction of +such mistakes seemed to be very clumsy in comparison with +modern typesetting. Then he decided (together with the second +author) to remedy the situation by creating an \APL\ font for +\TeX\ he was using for other kinds of document. Many of the +\APL\ symbols needed were contained in standard fonts; for example, +{\it diamond\/} can be found in {\it cmsy10}. For alphanumeric +characters one could use {\it cmsltt10}. The simplest try for +a solution of the problem would be to write a list of definitions +that pick symbols from appropriate fonts. However, this brute force +method does not really work since these symbols come from +very different typefaces and, moreover, do not provide a fixed +typeface. Hence, we decided to find an easy way of producing +an \APL\ font by using \METAFONT. + +As the starting point, we took the font {\it cmtex10}. This is a +fixed typeface for an extended typewriter-like font including +some Greek characters and mathematical symbols. The \METAFONT\ file +for this font, {\sltt cmtex10.mf\/} contains (as usual) a preamble +that assigns values to several global variables, and the command +{\sltt generate textset;\/}. Now the {\sl driver\/} file {\sltt textset.mf\/} %@@@@ +contains the commands {\sltt mode\_setup;font\_setup;\/} %@@@@ +(establishing the values of the variables for this font) and several +input files from which the \METAFONT\ descriptions of the characters are to +be found. Since some of these files treat the characters by name and +since some of the definitions have to be changed (and some dropped), +we considered it advisable to discard the driver file and to collect +the separate \METAFONT\ files, together with the preamble, to form a +large single file {\sltt cmapl10.mf}. The {\sltt .mf\/} character files +needed for {\sltt cmapl10.mf\/} are the following: +% +% +$$\vbox{\halign{{\sltt#}\hfil && \quad #\hfil\cr +% + greekl & ({\it rho, omega, alpha}) \cr + italms & ({\it iota}) \cr + romand & (roman digits) \cr + punct & (punctuation symbols) \cr + romanp & \cr + symbol & (math symbols) \cr + sym & \cr + romanu & (uppercase letters) \cr + romanl & (lowercase letters) \cr +% +}}$$ +% +% +\section{Definitions} +\choosett{tentt}% +The first thing to do is to put {\sltt font\_identifier:="CMAPL";\/} %@@@@ +and to set {\sltt slant:=0;\/} in the preamble. Many definitions can %@@@@ +be copied verbatim from the {\sltt .mf\/} files, but some of them +need changes. The Greek {\it iota}, as given in {\sltt greekl.mf}, +is strange to \APL\ style; we use instead the {\it dotless i\/} +from {\sltt italms.mf}. Moreover, we used the symbol {\it elt\/} +(element) from {\sltt sym.mf\/} instead of the Greek {\it epsilon}. +The symbols {\it del\/} and {\it delta\/} are +taken from {\sltt symbol.mf\/} (where their names are {\it large triangle\/} +and {\it large inverted triangle}). However, they are too sturdy +and too short to be placed in a proper \APL\ font. Further, {\it del\/} +must be lifted up so that it is vertically aligned with other +symbols. The modifications are very easy to do, and the modified %@@@@ , by ,and +definition is shown below. +% +% +\choosett{tentt} +\begintt + % sqrt48 was changed to 6.25 since the del symbol in APL has + % a narrower top than the original reversed triangle symbol + % rule.nib has been changed to light_rule.nib + % bot y3=-d-o has been changed to bot y3=0 + % top y1=h-d has been changed to top y1=h+2o + @null + cmchar "Del"; + beginchar(oct"002",16u#,asc_height#,0); + adjust_fit(0,0); pickup light_rule.nib; + top y1=h+2o; y2=y1; bot y3=0; + .5[x1,x2]=x3=good.x .5w; w:=r:=2x3; lft x1=hround(.5w-u*6.25); + draw z1--z2--z3--cycle; % stroke + labels(1,2,3); endchar; +\endtt +As can be seen from this example, pen strokes were made thinner. +Actually only one symbol was directly missing---this is the {\it quad +box}. However, it can be obtained from the above by adding one control point: +\begintt + cmchar "Quad"; + beginchar(oct"001",16u#,body_height#,0); + adjust_fit(0,0); pickup light_rule.nib; + bot y1=0; y2=y1; top y3=h+2o; y4=y3; + .5[x1,x2]=x5=good.x .5w; w:=r:=2x5; + % The quad box is slightly wider than Del + lft x1=hround(.5w-u*7); + x3=x1; x4=x2; + draw z1--z2--z4--z3--cycle; % box + labels(1,2,3,4); endchar; +\endtt +After taking care of special symbols, the letters can be treated +by finding a suitable value for {\it tilt ratio\/} (slant). Indeed, +\APL\ letters are {\sl very\/} slanted. We suggest the value +1/5 for this font (the font {\it cmsl10\/} uses 1/6). One should +remember to give the command {\sltt font\_setup;\/} after setting {\sltt slant\/} %@@@@ +to 1/5. +\choosett{sltt}% %@@@@ +Finally, one has to make the {\it verbatim\/} macros +suitable for \APL\ style. Since {\it verbatim\/} might be +used for several different fonts in one document, we decided +to include a control sequence @\choosett@. +\choosett{tentt} +\begintt + \def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax} + \newif\ifapl \def\aplname{apl} + \outer\def\choosett#1{\ifundefined{#1}% + \message{Undefined font(?), replaced with cmtt10}% + \let\tt=\tentt + \else + \def\tt{\expandafter\csname#1\endcsname}% + \def\ttname{#1}% + \ifx\ttname\aplname\apltrue\else\aplfalse\fi\fi} +\endtt +\choosett{sltt}% +(The control sequence @\ifundefined@ comes from the \TeX{book}, p.\ 308.) +With the help of @\choosett@, the standard @verbatim@ macros can be used +with the single change that @\ifapl@, then the @\catcode@ of @A@,\dots,@Z@ +is @\other@ (12) instead of 11 for {\it letter}. Under \APL\ mode \TeX\ +will then recognize our single-letter control sequences defined, e.g., by +\choosett{tentt} +\begintt + \def\A#1{\if#1B{\apl\char'174}\else % stile + \if#1M{\apl\char'004}\fi\fi} % alpha . +\endtt +\choosett{sltt}% +Unfortunately, we have redefined the standard @\L@, @\O@, @\P@ and @\S@. + +The \APL\ symbols not in the font table are obtained---as usual---by +overstriking two table symbols. +\choosett{tentt}% +\begintt + \newbox\firstchar\newskip\charwidth + \def\overstrike#1#2{\setbox\firstchar=\hbox{#1}\charwidth=\wd\firstchar + #1\hskip-\charwidth#2} +\endtt +\choosett{apl}% +For example, the {\it grade up\/} and {\it grade down\/} symbols +\G U\ and \G D\ are obtained by striking the {\it stile\/} symbol +@|@ over \L D\ and \D L, respectively. +\choosett{tentt}% +\begintt + \def\G#1{\if#1U{\overstrike{\LD}{\AB}}\else % grade up + \if#1D{\overstrike{\DL}{\AB}}\fi\fi} % grade down +\endtt +Now let us take another example on \APL. The input +\begintt + \choosett{apl} % in case some other choice is in force + \setbox0=\vbox{\hsize=5.7truein + \begintt + [0] Z_A1 PROD A2;A;I;V + [1] "RETURNS THE PRODUCT OF THE POLYNOMIALS A1 AND A2 + [2] "THE ARGUMENTS ARE GIVEN AS COEFFICIENT ARRAYS + [3] I_@@ROA1 + [4] Z_A1@@SO.#A2 + [5] LOOP:V_@@ROZ @@DM V[(@@ROI)+1]-1 + [6] V_@@ROZ_Z,[(@@ROI)+1]V@@RO0 + [7] A_(1+-@@IOV[1])@@SO.#((@@NT(@@IO@@ROV)@@EP(1,(@@ROI)+1))/V)@@RO1 + [8] Z_+/[1]A@@RV[(@@ROI)+1]Z + [9] ((@@RO@@ROZ)>@@ROI)/LOOP + @endsym + } + $$\boxit{\boxit{\box0}}$$ + \centerline{\sevenrm An APL function for polynomial multiplication} +\endtt +% +gives the output +% +\choosett{apl} +\setbox0=\vbox{\hsize=5.7truein +\begintt + [0] Z_A1 PROD A2;A;I;V + [1] "RETURNS THE PRODUCT OF THE POLYNOMIALS A1 AND A2 + [2] "THE ARGUMENTS ARE GIVEN AS COEFFICIENT ARRAYS + [3] I_@ROA1 + [4] Z_A1@SO.#A2 + [5] LOOP:V_@ROZ @DM V[(@ROI)+1]-1 + [6] V_@ROZ_Z,[(@ROI)+1]V@RO0 + [7] A_(1+-@IOV[1])@SO.#((@NT(@IO@ROV)@EP(1,(@ROI)+1))/V)@RO1 + [8] Z_+/[1]A@RV[(@ROI)+1]Z + [9] ((@RO@ROZ)>@ROI)/LOOP +\endtt + } +$$\boxit{\boxit{\box0}}$$ +\centerline{\sevenrm An APL function for polynomial multiplication} +% +\section{User extension} +A modern user of a computerized typesetting facility will probably +ask if it is possible to extend or modify fonts coming with the +system. As with [5], where the font has an {\it analytic\/} and a +{\it bitmapped\/} variant, we can distinguish between the need of modifying +{\it cmapl10\/} via \METAFONT\ and modification of the pixel files. +\APL\ symbols of various ``blackness'' or ``thickness'' may be desirable. +Indeed, in [3] the user input is written with boldface \APL\ symbols +and the answers from the interpreter with thin ones. Furthermore, +certain screen previewers use specific small size pixel files, and +do not support the \APL\ font. + +The modification of the font by changing the values of some global +variables in the preamble of the \METAFONT\ file is easy and can be +done by following how it is done in standard fonts such as +{\it cmbx10\/} etc. This is the recommended way, too. However, if +\METAFONT\ is not available, then one must attack the pixel files. +For direct hand editing, we use a program that converts a pixel +file into a (bitmapped) text file acceptable to any standard screen +editor, and another program reading the edited file back into +a \TeX\ pixel file. Scaling fonts down to a desired size can be +done in a similar (but automatic) manner; this facility is needed +by a previewer (written by the first author) not using runtime +scaling. + + +\section{References} +\bigskip +{ +\ref Digital Equipment Corporation: VAX-11 \APL\ Reference Manual.- + 1983. + +\ref Feldberg, Ian: TEXT: Publication-Quality Characters Come + to \APL\ Graphics.- Proceedings of the 1986 \APL\ Conference, + SIGAPL, pp.\ 306--313. + +\ref Gilman, Leonard, and Allen J.\ Rose: \APL, An Interactive + Approach.- John Wiley \& Sons, Inc., 1984. + +\ref Grenander, Ulf: Mathematical Experiments on the Computer.- + Academic Press, 1982. + +\ref Howland, John E.: Typesetting \APL\ Using a Macintosh.- + Proceedings of the 1986 \APL\ Conference, SIGAPL, pp.\ 301--305. + +\ref Iverson, Kenneth: A Programming Language.- Wiley, New York, 1962. + + + } + +\bigskip +\section{The address} +\bigskip +{\ninepoint\obeylines +\hskip\refskip University of Helsinki +\hskip\refskip Department of Mathematics +\hskip\refskip Hallituskatu 15 +\hskip\refskip SF--00100 HELSINKI +\hskip\refskip FINLAND +} + +\end + + +%============================================================================ +% +%============================================================================ diff --git a/Master/texmf-dist/doc/latex/apl/versatim.tex b/Master/texmf-dist/doc/latex/apl/versatim.tex new file mode 100644 index 00000000000..c2ff320a7e5 --- /dev/null +++ b/Master/texmf-dist/doc/latex/apl/versatim.tex @@ -0,0 +1,66 @@ + +%============================================================================= +% V E R S A T I M . T E X +%============================================================================= +% +% +\newskip\verbatimindent \verbatimindent=0cm +\newskip\ttglue{\tt \global\ttglue=.5em plus.25em minus.15em} +\def\@{\char'100 } +% +\outer\def\begindisplay{\obeylines\startdisplay} +{\obeylines\gdef\startdisplay#1 + {\catcode`\^^M=5$$#1\halign\bgroup&\hskip\verbatimindent##\hfil\cr}} +\outer\def\enddisplay{\crcr\egroup$$} +% +\chardef\other=12 +\def\ttverbatim{\begingroup \catcode`\\=\other \catcode`\{=\other + \catcode`\}=\other \catcode`\$=\other \catcode`\&=\other + \catcode`\#=\other \catcode`\%=\other \catcode`\~=\other + \catcode`\_=\other \catcode`\^=\other\catcode`\*=\other\catcode`\==\other +% +\ifapl +\catcode`\A=12 +\catcode`\B=12 +\catcode`\C=12 +\catcode`\D=12 +\catcode`\E=12 +\catcode`\F=12 +\catcode`\G=12 +\catcode`\H=12 +\catcode`\I=12 +\catcode`\J=12 +\catcode`\K=12 +\catcode`\L=12 +\catcode`\M=12 +\catcode`\N=12 +\catcode`\O=12 +\catcode`\P=12 +\catcode`\Q=12 +\catcode`\R=12 +\catcode`\S=12 +\catcode`\T=12 +\catcode`\U=12 +\catcode`\V=12 +\catcode`\W=12 +\catcode`\X=12 +\catcode`\Y=12 +\catcode`\Z=12 +\fi +% + \obeyspaces \obeylines \tt} +{\obeyspaces\gdef {\ }} +% +\def\begintt{$$\let\par=\endgraf \ttverbatim \parskip=0pt + \catcode`\@=0 \parindent=\verbatimindent \rightskip=-5pc \ttfinish} +{\catcode`\@=0 @catcode`@\=\other % @ is temporary escape character + @obeylines % end of line is active + @gdef@ttfinish#1^^M#2\endtt{#1@vbox{#2}@endgroup$$}} +% +\catcode`\@=\active +{\obeylines\gdef@{\ttverbatim\spaceskip=\ttglue\let^^M=\ \let@=\endgroup}} + + +\def\beginlines{\par\begingroup\nobreak\medskip\parindent=0pt + \kern1pt\nobreak \obeylines \everypar{\strut}} +\def\endlines{\kern1pt\endgroup\medbreak\noindent} |