2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -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>

View file

@ -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. */

View file

@ -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. */

View file

@ -0,0 +1,6 @@
variable more = 0, i;
foreach i ([1:10]) {
if (more) () = printf(", ");
printf("%d", i);
more = 1;
}