Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    r61dafb8 rba80f99  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Wed Nov  7 17:00:49 2018
    14 %% Update Count     : 3399
     13%% Last Modified On : Fri Aug 31 07:54:50 2018
     14%% Update Count     : 3396
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    547547
    548548
    549 \subsection{Loop Control}
     549%\subsection{\texorpdfstring{\protect\lstinline@for@ Statement}{for Statement}}
     550\subsection{\texorpdfstring{\LstKeywordStyle{for} Statement}{for Statement}}
    550551
    551552The ©for©/©while©/©do-while© loop-control allows empty or simplified ranges.
     
    556557the down-to range ©-~=©\index{-~=@©-~=©} means inclusive range [N,M].
    557558©0© is the implicit start value;
    558 ©1© is the implicit increment value.
    559 The up-to range uses ©+=© for increment;
    560 the down-to range uses ©-=© for decrement.
     559©1© is the implicit increment value for an up-to range and ©-1© for an implicit down-to range.
    561560The loop index is polymorphic in the type of the start value or comparison value when start is implicitly ©0©.
    562561\begin{cquote}
    563562\begin{tabular}{@{}ll|l@{}}
    564 \multicolumn{2}{c|}{loop control} & \multicolumn{1}{c}{output} \\
     563\multicolumn{2}{c|}{for control} & \multicolumn{1}{c}{output} \\
    565564\hline
    566565\begin{cfa}
     
    572571for ( ®10® ) { sout | "A"; }
    573572for ( ®1 ~= 10 ~ 2® ) { sout | "B"; }
    574 for ( ®10 -~= 1 ~ 2® ) { sout | "C"; }
     573for ( ®10 -~= 1 ~ -2® ) { sout | "C"; }
    575574for ( ®0.5 ~ 5.5® ) { sout | "D"; }
    576575for ( ®5.5 -~ 0.5® ) { sout | "E"; }
    577576for ( ®i; 10® ) { sout | i; }
    578577for ( ®i; 1 ~= 10 ~ 2® ) { sout | i; }
    579 for ( ®i; 10 -~= 1 ~ 2® ) { sout | i; }
     578for ( ®i; 10 -~= 1 ~ -2® ) { sout | i; }
    580579for ( ®i; 0.5 ~ 5.5® ) { sout | i; }
    581580for ( ®i; 5.5 -~ 0.5® ) { sout | i; }
    582581for ( ®ui; 2u ~= 10u ~ 2u® ) { sout | ui; }
    583 for ( ®ui; 10u -~= 2u ~ 2u® ) { sout | ui; }
    584 enum { N = 10 };
    585 for ( ®N® ) { sout | "N"; }
    586 for ( ®i; N® ) { sout | i; }
    587 for ( ®i; N -~ 0® ) { sout | i; }
    588 const int start = 3, comp = 10, inc = 2;
     582for ( ®ui; 10u -~= 2u ~ -2u® ) { sout | ui; }
     583int start = 3, comp = 10, inc = 2;
    589584for ( ®i; start ~ comp ~ inc + 1® ) { sout | i; }
    590585\end{cfa}
    591586&
    592587\begin{cfa}
    593 sout | endl;
    594 sout | endl;
    595 sout | endl;
    596 sout | "zero" | endl;
    597588sout | endl;
    598589sout | endl;
     
    607598sout | endl;
    608599sout | endl;
    609 sout | endl | endl;
    610 
    611600sout | endl;
    612601sout | endl;
    613 sout | endl | endl;
     602sout | endl;
     603sout | endl;
     604sout | endl;
    614605
    615606sout | endl;
     
    620611empty
    621612empty
    622 zero
     613
    623614A
    624615A A A A A A A A A A
     
    6346252 4 6 8 10
    63562610 8 6 4 2
    636 
    637 N N N N N N N N N N
    638 0 1 2 3 4 5 6 7 8 9
    639 10 9 8 7 6 5 4 3 2 1
    640627
    6416283 6 9
Note: See TracChangeset for help on using the changeset viewer.