Generator/Exponential: Difference between revisions

m
→‎{{header|REXX}}: added whitespace, change output gylphs. -- ~~~~
m (→‎{{header|REXX}}: deleted a superflous blank lines. -- ~~~~)
m (→‎{{header|REXX}}: added whitespace, change output gylphs. -- ~~~~)
Line 1,425:
/*how_many: show that many vals.*/
parse arg how_many; how_many=pick1(how_many 0)
 
do j=1 for how_many; call tell 'squares' ,gen_squares(j) ; end
do j=1 for to how_many; call tell 'cubessquares' ,gen_cubesgen_squares(j) ; ; end
do j=1 for to how_many; call tell 'sq¬cubes' ,gen_sqNcubesgen_cubes(j) ; end
do j=1 for to how_many; call tell 'squaressq¬cubes' ,gen_squaresgen_sqNcubes(j) ; end
if how_many>0 then say 'dropping 1st -->──► 20th values.'
do j=1 for 20; drop gen_.sqNcubes.j ; end
do j=20+1 for 10 to 20; call tell 'sq¬cubes',gen_sqNcubes( drop gen_.sqNcubes.j) ; end
do j=20+1 for 10 ; call tell 'sq¬cubes',gen_sqNcubes(j) ; end
exit
 
exit /*stick a fork in it, we're done.*/
 
/*─────────────────────────────────────generate powers iterator─────────*/
gen_powers: procedure expose gen_.; parse arg x,p; if x=='' then return
if gen_.powers.x.p=='' then gen_.powers.x.p=x**p
return gen_.powers.x.p
 
/*─────────────────────────────────────gen squares iterator─────────────*/
gen_squares: procedure expose gen_.; parse arg x; if x=='' then return
if gen_.squares.x=='' then do
call gen_powers x,2
Line 1,443 ⟶ 1,447:
end
return gen_.squares.x
 
/*─────────────────────────────────────gen cubes iterator───────────────*/
gen_cubes: procedure expose gen_.; parse arg x; if x=='' then return
if gen_.cubes.j=='' then do
call gen_powers x,3
Line 1,450 ⟶ 1,455:
end
return gen_.cubes.x
 
/*─────────────────────────────────────gen squares not cubes iterator───*/
gen_sqNcubes: procedure expose gen_.; parse arg x; if x=='' then return
s=1
if gen_.sqNcubes.x=='' then do j=1 to x
Line 1,469 ⟶ 1,475:
end /*j*/
return gen_.sqNcubes.x
 
/*─────────────────────────────────────"1─liner" subroutines────────────*/
tell: if j==1 then say /*format args to be aligned up. */
say right(arg(1),20) right(j,5) right(arg(2),20); return
 
pick1: return word(arg(1) arg(2),1)</lang>
'''output''' when using the default (no input)
Line 1,520 ⟶ 1,528:
sq¬cubes 9 121
sq¬cubes 10 144
dropping 1st -->──► 20th values.
sq¬cubes 21 529
sq¬cubes 22 576