Ludic numbers: Difference between revisions

→‎{{header|REXX}}: optimized program, only invoke the ludic function once.
(→‎{{header|REXX}}: retroduce part of the program that was overlooked.)
(→‎{{header|REXX}}: optimized program, only invoke the ludic function once.)
Line 2,887:
if top=='' | top=="," then top=2005 /* " " " " " " */
if triples=='' | triples=="," then triples=250-1 /* " " " " " " */
$=ludic( max(N, count, bot, top, triples) ) /*generate enough ludic nums.*/
say 'The first ' N " ludic numbers: " ludic subword(n$,1,25) /*display title1st for what'sN coming nextludic nums.*/
$=ludic(count); @=
do j=1 until word($, j) > count; @=@ _;end end /*only process up to a specific number#.*/
say
say "There are " words(@)j-1 ' ludic numbers that are ≤ ' count
say
say "The " bot '───►' top ' (inclusive) ludic numbers are: ' subword(ludic(top)$, bot)
#=0
$=ludic(triples); #=0; @=
@=; do j=1 for words($); _=word($,j) /*it is known that ludic _ exists. */
say
do j=1 for words($); _=word($,j) /*it is known that ludic _ exists. */
if _>=triples then leave /*only process up to a specific number.*/
if wordpos(_+2, $)==0 | wordpos(_+6, $)==0 then iterate /*Not triple? Skip it.*/
#=#+1; @=@ '◄'_ _+2 _+6"► " /*bump the triple counter, and ··· */
end /*j*/ /* [↑] append the found triple ──► @ */
say
 
if @=='' then say 'From 1──►'triples", no triples found."
else say 'From 1──►'triples", " # ' triples found:' @
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
ludic: procedure; parse arg m,,@; $=1 2 /*$≡ludic numbers superset; @≡sequence*/
do j=3 by 2 to m*15; @=@ j; end /*construct an initial list of numbers.*/
@=@' j '; n=words(@) /*append ana odd numberblank to the number sequence.*/
end /*j*/
@=@' '; n=words(@) /*append a blank to the number sequence*/
do while n\==0; f=word(@,1); $=$ f /*examine the first word in @; add to $*/
do d=1 by f while d<=n; n=n-1 /*use 1st number, elide all occurrances*/
Line 2,917 ⟶ 2,914:
@=translate(@, , .) /*change dots to blanks; count numbers.*/
end /*while*/ /* [↑] done eliding ludic numbers. */
return subword($, 1, m) /*return a range of ludic numbers. */</lang>
 
return subword($, 1, m) /*return a range of ludic numbers. */</lang>
Some older REXXes don't have a &nbsp; '''changestr''' &nbsp; BIF, &nbsp; so one is included here &nbsp; ──► &nbsp; [[CHANGESTR.REX]].
<br><br>