X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw-algo.tex;h=3d76de07ce80dc1cec769803981a285a20a19c72;hb=18104ac1a84b61b09564bd3d8ab0948e502c51e3;hp=cb65f042bdcf0b74d74f59e210d4dbc168277705;hpb=1b2fdb338bf50410001853b35d05f5883bd9b076;p=ucwmac.git diff --git a/ucw-algo.tex b/ucw-algo.tex index cb65f04..3d76de0 100644 --- a/ucw-algo.tex +++ b/ucw-algo.tex @@ -7,17 +7,18 @@ % \algo{name of the algorithm}\algalias{a longer name} % \algin input description % \:step -% \:step +% \:step \cmt{comment} % \::[identifier]nested step % \:::yet more nested step % \algout output description % \endalgo % Localized strings -\localedef{en}{alg:alg}{Algorithm} -\localedef{en}{alg:proc}{Procedure} -\localedef{en}{alg:in}{Input} -\localedef{en}{alg:out}{Output} +\localedef{0}{alg:alg}{Algorithm} +\localedef{0}{alg:proc}{Procedure} +\localedef{0}{alg:func}{Function} +\localedef{0}{alg:in}{Input} +\localedef{0}{alg:out}{Output} % Item indent \newdimen\algoindent @@ -53,21 +54,22 @@ \def\algostep#1{\hbox to \algolabelwidth{\hss #1~~}} \def\algoinit{ - \goodbreak \begingroup \algospacing \inititemize \let\:=\algoitem \def\={\leftarrow} + \let\cmt=\algcmt \itemcount=0 } \def\typedalgo#1#2{\algoinit {\bo #1\/} \alg{#2}} \def\algo#1{\typedalgo{\localestr{alg:alg}}{#1}} \def\proc#1{\typedalgo{\localestr{alg:proc}}{#1}} +\def\func#1{\typedalgo{\localestr{alg:func}}{#1}} \def\headlessalgo{\algoinit} -\def\endalgo{\goodbreak\endlist\endgroup} +\def\endalgo{\endlist\endgroup} \let\endproc=\endalgo \def\algoitem{% @@ -82,9 +84,13 @@ \optdef\algoitemgo{\ifx\addid\undefined\else\addid{item}{\the\itemcount}\fi} \def\algin{\par\nobreak{\it \localestr{alg:in}:\/} } -\def\algout{\par\nobreak\parindent=0pt{\it \localestr{alg:in}:\/} } -\def\alginbreak{\hfil\break\hphantom{\it \localestr{alg:out}:\/} } +\def\algout{\par\nobreak\parindent=0pt{\it \localestr{alg:out}:\/} } +\def\alginbreak{\hfil\break\hphantom{\it \localestr{alg:in}:\/} } \def\algalias#1{ (#1)} % Algorithm name in text or in a formula \protected\def\alg#1{\leavevmode\hbox{\csc #1}} + +% Comments +\def\algcmt#1{\unskip~~\hfill\fullcmt{#1}\ignorespaces} +\def\fullcmt#1{{$\triangleleft$\hskip0.5em\it #1}}