Generator/Exponential: Difference between revisions
Content added Content deleted
(→{{header|REXX}}: added the REXX language. -- ~~~~) |
m (→{{header|REXX}}: added more comments to the REXX code. -- ~~~~) |
||
Line 1,316: | Line 1,316: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
Code was added to support listing of so many values, the default is 0 (zero). |
Code was added to support listing of so many values, the default is 0 (zero). |
||
<br>The generators lie dormant until a request is made (illustrated by the calling of "TELL" to display some values). |
|||
<br>A lot of unnecessary iterator calls could be eliminated (and making the program a lot faster) if a check would be made to determine if a value has been emitted. |
|||
<br>The REXX program can handle any numbers, not just positive integers; one only need to increase the size of the DIGITS if more are needed. |
|||
<lang rexx> |
<lang rexx> |
||
/*REXX program to show how to use a generator (also known as iterators).*/ |
/*REXX program to show how to use a generator (also known as iterators).*/ |
||
numeric digits 10000 /*just in case we need big 'uns. */ |
|||
/*────── on any numbers, not just integers. */ |
|||
/*Generator (POWERS): generate (integer) powers */ |
|||
/*Generator (SQUARES): generate squares */ |
|||
/*Generator (CUBES): generate cubes */ |
|||
/*Generator (SQNCUBE): generate squares that have no cubes. */ |
|||
gen_.= /*have generators from scratch. */ |
gen_.= /*have generators from scratch. */ |
||
/*how_many: show that many vals.*/ |
/*how_many: show that many vals.*/ |