Changes in doc/user/user.tex [61dafb8:ba80f99]
- File:
-
- 1 edited
-
doc/user/user.tex (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/user/user.tex
r61dafb8 rba80f99 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Wed Nov 7 17:00:49201814 %% Update Count : 339 913 %% Last Modified On : Fri Aug 31 07:54:50 2018 14 %% Update Count : 3396 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 547 547 548 548 549 \subsection{Loop Control} 549 %\subsection{\texorpdfstring{\protect\lstinline@for@ Statement}{for Statement}} 550 \subsection{\texorpdfstring{\LstKeywordStyle{for} Statement}{for Statement}} 550 551 551 552 The ©for©/©while©/©do-while© loop-control allows empty or simplified ranges. … … 556 557 the down-to range ©-~=©\index{-~=@©-~=©} means inclusive range [N,M]. 557 558 ©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. 561 560 The loop index is polymorphic in the type of the start value or comparison value when start is implicitly ©0©. 562 561 \begin{cquote} 563 562 \begin{tabular}{@{}ll|l@{}} 564 \multicolumn{2}{c|}{ loopcontrol} & \multicolumn{1}{c}{output} \\563 \multicolumn{2}{c|}{for control} & \multicolumn{1}{c}{output} \\ 565 564 \hline 566 565 \begin{cfa} … … 572 571 for ( ®10® ) { sout | "A"; } 573 572 for ( ®1 ~= 10 ~ 2® ) { sout | "B"; } 574 for ( ®10 -~= 1 ~ 2® ) { sout | "C"; }573 for ( ®10 -~= 1 ~ -2® ) { sout | "C"; } 575 574 for ( ®0.5 ~ 5.5® ) { sout | "D"; } 576 575 for ( ®5.5 -~ 0.5® ) { sout | "E"; } 577 576 for ( ®i; 10® ) { sout | i; } 578 577 for ( ®i; 1 ~= 10 ~ 2® ) { sout | i; } 579 for ( ®i; 10 -~= 1 ~ 2® ) { sout | i; }578 for ( ®i; 10 -~= 1 ~ -2® ) { sout | i; } 580 579 for ( ®i; 0.5 ~ 5.5® ) { sout | i; } 581 580 for ( ®i; 5.5 -~ 0.5® ) { sout | i; } 582 581 for ( ®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; 582 for ( ®ui; 10u -~= 2u ~ -2u® ) { sout | ui; } 583 int start = 3, comp = 10, inc = 2; 589 584 for ( ®i; start ~ comp ~ inc + 1® ) { sout | i; } 590 585 \end{cfa} 591 586 & 592 587 \begin{cfa} 593 sout | endl;594 sout | endl;595 sout | endl;596 sout | "zero" | endl;597 588 sout | endl; 598 589 sout | endl; … … 607 598 sout | endl; 608 599 sout | endl; 609 sout | endl | endl;610 611 600 sout | endl; 612 601 sout | endl; 613 sout | endl | endl; 602 sout | endl; 603 sout | endl; 604 sout | endl; 614 605 615 606 sout | endl; … … 620 611 empty 621 612 empty 622 zero 613 623 614 A 624 615 A A A A A A A A A A … … 634 625 2 4 6 8 10 635 626 10 8 6 4 2 636 637 N N N N N N N N N N638 0 1 2 3 4 5 6 7 8 9639 10 9 8 7 6 5 4 3 2 1640 627 641 628 3 6 9
Note:
See TracChangeset
for help on using the changeset viewer.