2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,10 +1,17 @@
|
|||
Quite often one needs loops which, in the last iteration,
|
||||
execute only part of the loop body. pas
|
||||
The goal of this task is to demonstrate the best way to do this.
|
||||
Quite often one needs loops which, in the last iteration, execute only part of the loop body.
|
||||
|
||||
|
||||
;Goal:
|
||||
Demonstrate the best way to do this.
|
||||
|
||||
|
||||
;Task:
|
||||
Write a loop which writes the comma-separated list
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
|
||||
using separate output statements for the number
|
||||
and the comma from within the body of the loop.
|
||||
|
||||
See also: [[Loop/Break]]
|
||||
|
||||
;Related task:
|
||||
* [[Loop/Break]]
|
||||
<br><br>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*REXX program to display: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 */
|
||||
/*REXX program displays: 1,2,3,4,5,6,7,8,9,10 */
|
||||
|
||||
do j=1 to 10
|
||||
call charout ,j /*write the DO loop index (no LF)*/
|
||||
if j<10 then call charout ,", " /*append a comma for 1-digit nums*/
|
||||
end /*j*/
|
||||
/*stick a fork in it, we're done.*/
|
||||
do j=1 to 10
|
||||
call charout ,j /*write the DO loop index (no LF). */
|
||||
if j<10 then call charout ,"," /*append a comma for one-digit numbers.*/
|
||||
end /*j*/
|
||||
/*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*REXX program to display: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 */
|
||||
/*REXX program displays: 1,2,3,4,5,6,7,8,9,10 */
|
||||
|
||||
do j=1 for 10 /*using FOR is faster than TO.*/
|
||||
call charout ,j ||copies(', ',j<10) /*show J, maybe append a comma.*/
|
||||
end /*j*/
|
||||
/*stick a fork in it, we're done.*/
|
||||
do j=1 for 10 /*using FOR is faster than TO. */
|
||||
call charout ,j || left(',',j<10) /*display J, maybe append a comma (,).*/
|
||||
end /*j*/
|
||||
/*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
variable more = 0, i;
|
||||
foreach i ([1:10]) {
|
||||
if (more) () = printf(", ");
|
||||
printf("%d", i);
|
||||
more = 1;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue