Talk:Permutations with repetitions: Difference between revisions
Content added Content deleted
m (→REXX implementation limits: added comments about various releases of Regina REXX. -- ~~~~) |
(→REXX implementation limits: added another variant of REXX version 2. -- ~~~~) |
||
Line 40: | Line 40: | ||
::::::::::: -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 20:52, 12 May 2013 (UTC) |
::::::::::: -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 20:52, 12 May 2013 (UTC) |
||
---- |
|||
==another variant of the 2nd REXX version== |
|||
This REXX version: |
|||
* simplifies many statements |
|||
* minimizes the length of the INTERPRET statement |
|||
* eliminates the SELECT statements |
|||
* eliminates a DO loop |
|||
* uses both kinds of quotes strings to make it easier to peruse |
|||
* moves a couple of statements out of the INTERPRET clause |
|||
* uses a positive (logic) instead of a negative IF statement |
|||
* eliminates an extra ''';''' (semicolon) from the INTERPRET clause |
|||
* eliminates the need for counting the permutations |
|||
<br>If any of these improvements could/would be of use, that's fine. I plan to delete this entry in a couple of weeks. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 04:32, 13 May 2013 (UTC) |
|||
<lang rexx>/*REXX*/ parse arg n m s names |
|||
if n='' then n=3 |
|||
if m='' then m=2 |
|||
if datatype(s,'N') then s=left('',s) |
|||
do k=1 to n |
|||
if names='' then e.k=k |
|||
else parse var names e.k names |
|||
end /*k*/ |
|||
a='' |
|||
do i=1 to m; a=a'do d'i"=1 to n;"; end /*i*/ |
|||
a=a'z=e.d1' |
|||
do j=2 to m; a=a"||s||e.d"j; end /*j*/ |
|||
a=a';say z'copies(";end",m) |
|||
if m==0 then do; say '1 permutation, a "null".'; exit; end |
|||
interpret a |
|||
say n**m 'permutations'</lang> |