Anonymous user
Permutations: Difference between revisions
m
→numbers: added whitespace, changed comments and indentation. -- ~~~~
m (→numbers: added whitespace, changed comments and indentation. -- ~~~~) |
|||
Line 2,608:
This version is modeled after the Maxima program (as far as output).
<br><br>It doesn't have the formatting capabilities of REXX version 1, nor can it handle taking '''X''' items taken ''' Y ''' at-a-time.
<lang rexx>/*REXX program shows permutations of
parse arg n .; if n=='' then n=3 /*Not specified?
/*populate the first permutation.*/
do pop=1 for n;
do while nextperm(n,0); call tell n; end
Line 2,618:
nextperm: procedure expose @.; parse arg n,i; nm=n-1
do k=nm by -1 for nm;
if @.k<@.kp then do;
end /*k*/
do j=i+1 while j<n; parse value @.j @.n with @.n @.j; n=n-1; end
if i==0 then return 0
do j=i+1 while @.j<@.i; end
parse value @.j @.i with @.i @.j
return 1
/*──────────────────────────────────TELL subroutine─────────────────────*/
|