Permutations: Difference between revisions

m
→‎{{header|REXX}}: removed OVERFLOW from PRE html tags.
m (→‎{{header|REXX}}: removed OVERFLOW from PRE html tags.)
Line 2,956:
do k=1 for x /*build a list of (perm) symbols.*/
_=p(word(uSyms,k) p(substr(@0abcS,k,1) k)) /*get|generate a symbol.*/
if length(_)\==1 then sep='_' /*if not 1st char, then use sep. */
$.k=_ /*append it to the symbol list. */
end /*k*/
 
if between=='' then between=sep /*use the appropriate separator. */
call .permset 1 /*start with the first permuation*/
list='$. @. between x y'
call .permset 1
return
/*──────────────────────────────────.PERMSET subroutine─────────────────*/
.permset: procedure expose (list)$. @. between x y; parse arg ?
if ?>y then do; _=@.1; do j=2 to y; _=_||between||@.j; end; say _; end
else do q=1 for x /*build permutation recursively. */
Line 2,972 ⟶ 2,971:
end /*q*/
return</lang>
'''output''' when the following was used for input: &nbsp; <tt> 3 3 </tt>
<pre>
123
Line 2,981 ⟶ 2,980:
321
</pre>
'''output''' when the following was used for input: &nbsp; <tt> 4 4 --- A B C D </tt>
<pre style="height:15ex;overflow:scroll">
A---B---C---D
A---B---D---C
Line 3,008 ⟶ 3,007:
D---C---B---A
</pre>
'''output''' when the following was used for input: &nbsp; <tt> 4 3 - aardvark gnu stegosaurus platypus </tt>
<pre style="height:15ex;overflow:scroll">
aardvark-gnu-stegosaurus
aardvark-gnu-platypus
Line 3,038 ⟶ 3,037:
===numbers===
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, &nbsp; nor can it handle taking &nbsp; '''X''' &nbsp; items taken &nbsp; ''' Y ''' &nbsp; at-a-time.
<lang rexx>/*REXX program shows permutations of N number of objects (1,2,3, ...).*/
parse arg n .; if n=='' then n=3 /*Not specified? Assume default.*/
Line 3,062 ⟶ 3,061:
tell: procedure expose @.; _=; do j=1 for arg(1);_=_ @.j;end; say _;return</lang>
'''output'''
<pre>
<pre style="overflow:scroll">
1 2 3
1 3 2