Talk:Permutations with repetitions: Difference between revisions

m (→‎another variant of the: changed the section header name. -- ~~~~)
 
(One intermediate revision by one other user not shown)
Line 62:
<br>If any of these improvements could/would be of use, that's fine. &nbsp; I plan to delete this entry in a couple of weeks. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 04:2013 (UTC)
<lang rexx>/*REXX*/ parse arg n m s names
if n='' then n=='' then m=(s,'N') then s=left('',s)3
if m='' then m=2
 
if do k=names=datatype(s,'N' ) then e.ks=kleft('',s)
else parse var names e.k names
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>
 
== Isn't it just similar to "Increment_a_numerical_string" ==
 
You set the length of the string to n fill it completly with "0" and set the base to k.
http://rosettacode.org/wiki/Increment_a_numerical_string#Pascal
Of course you can use an array of integer instead.
Anonymous user