2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,20 +1,19 @@
|
|||
/*REXX program selects all even numbers from an array ──► a new array.*/
|
||||
parse arg N seed . /*get optional parameters from CL*/
|
||||
if N=='' | N==',' then N=50 /*Not specified? Then use default*/
|
||||
if seed\=='' & seed\==',' then call random ,,seed /*for repeatability.*/
|
||||
old.= /*the OLD array, all null so far.*/
|
||||
new.= /*the NEW array, all null so far.*/
|
||||
do i=1 for N /*gen N random numbers ──► OLD*/
|
||||
old.i=random(1,99999) /*randum number 1 ──► 99999 */
|
||||
/*REXX program selects all even numbers from an array and puts them ──► a new array.*/
|
||||
parse arg N seed . /*obtain optional arguments from the CL*/
|
||||
if N=='' | N=="," then N=50 /*Not specified? Then use the default.*/
|
||||
if datatype(seed,'W') then call random ,,seed /*use the RANDOM seed for repeatability*/
|
||||
old.= /*the OLD array, all are null so far. */
|
||||
new.= /* " NEW " " " " " " */
|
||||
do i=1 for N /*generate N random numbers ──► OLD */
|
||||
old.i=random(1,99999) /*generate random number 1 ──► 99999*/
|
||||
end /*i*/
|
||||
#=0 /*numb. of elements in NEW so far*/
|
||||
do j=1 for N /*process the OLD array elements.*/
|
||||
if old.j//2 \== 0 then iterate /*if element isn't even, skip it.*/
|
||||
#=#+1 /*bump the number of NEW elements*/
|
||||
new.#=old.j /*assign it to the NEW array. */
|
||||
#=0 /*number of elements in NEW (so far).*/
|
||||
do j=1 for N /*process the elements of the OLD array*/
|
||||
if old.j//2 \== 0 then iterate /*if element isn't even, then skip it.*/
|
||||
#=#+1 /*bump the number of NEW elements. */
|
||||
new.#=old.j /*assign the number to the NEW array.*/
|
||||
end /*j*/
|
||||
|
||||
do k=1 for # /*display all the NEW numbers. */
|
||||
say right('new.'k, 20) "=" right(new.k,9) /*show a line*/
|
||||
end /*k*/
|
||||
/*stick a fork in it, we're done.*/
|
||||
do k=1 for # /*display all the NEW numbers. */
|
||||
say right('new.'k, 20) "=" right(new.k,9) /*display a line (an array element). */
|
||||
end /*k*/ /*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
/*REXX pgm find all even numbers from an array, marks a control array. */
|
||||
arse arg N seed . /*get optional parameters from CL*/
|
||||
f N=='' | N==',' then N=50 /*Not specified? Then use default*/
|
||||
f seed\=='' & seed\==',' then call random ,,seed /*for repeatability.*/
|
||||
/*REXX program finds all even numbers from an array, and marks a control array. */
|
||||
parse arg N seed . /*obtain optional arguments from the CL*/
|
||||
if N=='' | N=="," then N=50 /*Not specified? Then use the default.*/
|
||||
if datatype(seed,'W') then call random ,,seed /*use the RANDOM seed for repeatability*/
|
||||
|
||||
do i=1 for N /*gen N random numbers ──► OLD*/
|
||||
@.i=random(1,99999) /*randum number 1 ──► 99999 */
|
||||
end /*i*/
|
||||
.=0 /*numb. of elements in NEW so far*/
|
||||
do j=1 for N /*process the OLD array elements.*/
|
||||
if @.j//2 \==0 then !.j=1 /*mark ! array that it's ¬even.*/
|
||||
end /*j*/
|
||||
do i=1 for N /*generate N random numbers ──► OLD */
|
||||
@.i=random(1,99999) /*generate random number 1 ──► 99999*/
|
||||
end /*i*/
|
||||
!.=0 /*number of elements in NEW (so far).*/
|
||||
do j=1 for N /*process the OLD array elements. */
|
||||
if @.j//2 \==0 then !.j=1 /*mark the ! array that it's ¬even. */
|
||||
end /*j*/
|
||||
|
||||
do k=1 for N /*display all the @ even numbers.*/
|
||||
if !.k then iterate /*if it's marked ¬even, skip it.*/
|
||||
say right('array.'k, 20) "=" right(@.k,9) /*show a line*/
|
||||
end /*k*/
|
||||
/*stick a fork in it, we're done.*/
|
||||
do k=1 for N /*display all the @ even numbers. */
|
||||
if !.k then iterate /*if it's marked as not even, skip it.*/
|
||||
say right('array.'k, 20) "=" right(@.k,9) /*display a even number, filtered array*/
|
||||
end /*k*/ /*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
/*REXX pgm find all even numbers from an array, marks ¬ even numbers. */
|
||||
parse arg N seed . /*get optional parameters from CL*/
|
||||
if N=='' | N==',' then N=50 /*Not specified? Then use default*/
|
||||
if seed\=='' & seed\==',' then call random ,,seed /*for repeatability.*/
|
||||
/*REXX program finds all even numbers from an array, and marks the not even numbers.*/
|
||||
parse arg N seed . /*obtain optional arguments from the CL*/
|
||||
if N=='' | N=="," then N=50 /*Not specified? Then use the default.*/
|
||||
if datatype(seed,'W') then call random ,,seed /*use the RANDOM seed for repeatability*/
|
||||
|
||||
do i=1 for N /*gen N random numbers ──► OLD*/
|
||||
@.i=random(1,99999) /*randum number 1 ──► 99999 */
|
||||
do i=1 for N /*generate N random numbers ──► OLD */
|
||||
@.i=random(1,99999) /*generate a random number 1 ──► 99999 */
|
||||
end /*i*/
|
||||
|
||||
do j=1 for N /*process the OLD array elements.*/
|
||||
if @.j//2 \==0 then @.j= /*mark @ array that it's ¬even.*/
|
||||
do j=1 for N /*process the OLD array elements. */
|
||||
if @.j//2 \==0 then @.j= /*mark the @ array that it's not even*/
|
||||
end /*j*/
|
||||
|
||||
do k=1 for N /*display all the @ even numbers.*/
|
||||
if @.k=='' then iterate /*if it's marked ¬even, skip it.*/
|
||||
say right('array.'k, 20) "=" right(@.k,9) /*show a line*/
|
||||
end /*k*/
|
||||
/*stick a fork in it, we're done.*/
|
||||
do k=1 for N /*display all the @ even numbers. */
|
||||
if @.k=='' then iterate /*if it's marked not even, then skip it*/
|
||||
say right('array.'k, 20) "=" right(@.k,9) /*display a line (an array element). */
|
||||
end /*k*/ /*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue