Circular shifting

The operations on texts HEAD and TAIL that are available in Elan-0 differ markedly from the standard operations in the language, being much more list-oriented. In standard Elan they can be programmed as


\begin{elan}
TEXT OP HEAD ( TEXT CONST a ) :
a SUB 1
ENDOP HEAD ;
\par
TEXT OP TAIL ( TEXT CONST a ) :
subtext ( 2 , LENGTH a , a )
ENDOP TAIL ;
\end{elan}

The following program repeatedly rotates its input text by one position until the original is obtained again.


\begin{elan}
rotate :
declare texts ;
REP
shift s circularly ;
display ...
...t ( s ) .
\par
shift s circularly :
s := ( TAIL s ) + ( HEAD s ) .
\end{elan}