Am 30.11.2008 um 17:09 schrieb Zhaopeng Xing:
Hi,
Does anyone know how to describe algorithm procedures in similar way as LaTeX algorithmic and algorithm packages? I tried to search it on wiki but found nothing. Thanks.
Feel free to write your own module. \definefloat[algorithm][algorithms] \definestartstop [algorithm] [before=\startlines, after=\stoplines, commands=\directsetup{algorithm}] \startsetups algorithm \def\STATE {\hskip1em} \def\REQUIRE {{\bf Require: }} \def\ENSURE {{\bf Ensure: }} \def\IF ##1{\bgroup\doadaptleftskip{1em}{\bf if} ##1 {\bf then}} \def\ENDIF {{\bf end if}\par\egroup} \def\WHILE ##1{\bgroup\doadaptleftskip{1em}{\bf while} ##1 {\bf do}} \def\ENDWHILE {{\bf end while}\par\egroup} \definecomplexorsimple\ELSE \def\simpleELSE {{\bf else}} \def\complexELSE[##1]{{\bf else} $//$ ##1} \stopsetups %\setuplines[before=,after=] \starttext \startbuffer[algorithm] \startalgorithm \REQUIRE $n \geq 0 \vee x \neq 0$ \ENSURE $y = x^n$ \STATE $y \Leftarrow 1$ \IF{$n < 0$} \STATE $X \Leftarrow 1 / x$ \STATE $N \Leftarrow -n$ \ELSE \STATE $X \Leftarrow x$ \STATE $N \Leftarrow n$ \ENDIF \WHILE{$N \neq 0$} \IF{$N$ is even} \STATE $X \Leftarrow X \times X$ \STATE $N \Leftarrow N / 2$ \ELSE[$N$ is odd] \STATE $y \Leftarrow y \times X$ \STATE $N \Leftarrow N - 1$ \ENDIF \ENDWHILE \stopalgorithm \stopbuffer \typebuffer \getbuffer %\placealgorithm % {Calculate $y = x^n$} % {\framed[frame=off,align=right,width=fit,strut=no] {\getbuffer[algorithm]}} \stoptext Wolfgang