Changeset 76beed8 for doc/user


Ignore:
Timestamp:
Nov 2, 2018, 7:44:08 AM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
30ee9efc
Parents:
b6ad601
Message:

update documentation for loop control

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    rb6ad601 r76beed8  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Fri Aug 31 07:54:50 2018
    14 %% Update Count     : 3396
     13%% Last Modified On : Fri Nov  2 07:27:24 2018
     14%% Update Count     : 3397
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    547547
    548548
    549 %\subsection{\texorpdfstring{\protect\lstinline@for@ Statement}{for Statement}}
    550 \subsection{\texorpdfstring{\LstKeywordStyle{for} Statement}{for Statement}}
     549\subsection{Loop Control}
    551550
    552551The ©for©/©while©/©do-while© loop-control allows empty or simplified ranges.
     
    557556the down-to range ©-~=©\index{-~=@©-~=©} means inclusive range [N,M].
    558557©0© is the implicit start value;
    559 ©1© is the implicit increment value for an up-to range and ©-1© for an implicit down-to range.
     558©1© is the implicit increment value.
     559The up-to range uses ©+=© for increment;
     560the down-to range uses ©-=© for decrement.
    560561The loop index is polymorphic in the type of the start value or comparison value when start is implicitly ©0©.
    561562\begin{cquote}
    562563\begin{tabular}{@{}ll|l@{}}
    563 \multicolumn{2}{c|}{for control} & \multicolumn{1}{c}{output} \\
     564\multicolumn{2}{c|}{loop control} & \multicolumn{1}{c}{output} \\
    564565\hline
    565566\begin{cfa}
     
    571572for ( ®10® ) { sout | "A"; }
    572573for ( ®1 ~= 10 ~ 2® ) { sout | "B"; }
    573 for ( ®10 -~= 1 ~ -2® ) { sout | "C"; }
     574for ( ®10 -~= 1 ~ 2® ) { sout | "C"; }
    574575for ( ®0.5 ~ 5.5® ) { sout | "D"; }
    575576for ( ®5.5 -~ 0.5® ) { sout | "E"; }
    576577for ( ®i; 10® ) { sout | i; }
    577578for ( ®i; 1 ~= 10 ~ 2® ) { sout | i; }
    578 for ( ®i; 10 -~= 1 ~ -2® ) { sout | i; }
     579for ( ®i; 10 -~= 1 ~ 2® ) { sout | i; }
    579580for ( ®i; 0.5 ~ 5.5® ) { sout | i; }
    580581for ( ®i; 5.5 -~ 0.5® ) { sout | i; }
    581582for ( ®ui; 2u ~= 10u ~ 2u® ) { sout | ui; }
    582 for ( ®ui; 10u -~= 2u ~ -2u® ) { sout | ui; }
     583for ( ®ui; 10u -~= 2u ~ 2u® ) { sout | ui; }
    583584int start = 3, comp = 10, inc = 2;
    584585for ( ®i; start ~ comp ~ inc + 1® ) { sout | i; }
     
    586587&
    587588\begin{cfa}
     589sout | endl;
     590sout | endl;
     591sout | endl;
     592sout | "zero" | endl;
    588593sout | endl;
    589594sout | endl;
     
    598603sout | endl;
    599604sout | endl;
    600 sout | endl;
    601 sout | endl;
    602 sout | endl;
    603 sout | endl;
    604 sout | endl;
     605sout | endl | endl;
    605606
    606607sout | endl;
     
    611612empty
    612613empty
    613 
     614zero
    614615A
    615616A A A A A A A A A A
Note: See TracChangeset for help on using the changeset viewer.