Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,37 +1,37 @@
|
|||
/*REXX pgm generates all permutations of N different objects by swapping*/
|
||||
parse arg things bunch inbetween names /*get optional C.L. args*/
|
||||
if things=='' | things==',' then things=4 /*use the default? */
|
||||
if bunch =='' | bunch ==',' then bunch =things /* " " " */
|
||||
/* ┌────────────────────────────────────────────────────────────────┐
|
||||
│ things (optional) defaults to 4. │
|
||||
│ bunch (optional) defaults to THINGS. │
|
||||
│ inbetween (optional) defaults to a [null]. │
|
||||
│ names (optional) defaults to digits (and letters). │
|
||||
└────────────────────────────────────────────────────────────────┘ */
|
||||
parse arg things bunch inbetween names /*get optional arguments from CL.*/
|
||||
things=p(things 4) /*use the default for THINGS ? */
|
||||
bunch =p(bunch things) /* " " " " BUNCH ? */
|
||||
/*╔════════════════════════════════════════════════════════════════╗
|
||||
║ things (optional) defaults to 4. ║
|
||||
║ bunch (optional) defaults to THINGS. ║
|
||||
║ inbetween (optional) defaults to a [null]. ║
|
||||
║ names (optional) defaults to digits (and letters). ║
|
||||
╚════════════════════════════════════════════════════════════════╝*/
|
||||
upper inbetween; if inbetween=='NONE' | inbetween="NULL" then inbetween=
|
||||
call permSets things, bunch, inbetween, names
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*──────────────────────────────────! {factorial} subroutine────────────*/
|
||||
!: procedure; parse arg x; !=1; do j=2 to x; !=!*j; end; return !
|
||||
/*──────────────────────────────────one─liner subrlutines───────────────*/
|
||||
!: procedure; !=1; do j=2 to arg(1); !=!*j; end; return !
|
||||
p: return word(arg(1), 1) /*pick the first word from a list*/
|
||||
/*──────────────────────────────────GETONE subroutine───────────────────*/
|
||||
getOne: if length(z)==y then return substr(z,arg(1),1)
|
||||
else return sep||word(translate(z,,','),arg(1) )
|
||||
/*──────────────────────────────────P subroutine (Pick one)─────────────*/
|
||||
p: return word(arg(1),1)
|
||||
getOne: if length(z)==y then return substr(z,arg(1),1)
|
||||
else return sep||word(translate(z,,','), arg(1))
|
||||
/*──────────────────────────────────PERMSETS subroutine─────────────────*/
|
||||
permSets: procedure; parse arg x,y,between,uSyms /*X things Y at a time.*/
|
||||
sep=; !.=0 /*X can't be > length(@0abcs). */
|
||||
@abc = 'abcdefghijklmnopqrstuvwxyz'; parse upper var @abc @abcU
|
||||
@abcS= @abcU || @abc; @0abcS=123456789 || @abcS
|
||||
z=
|
||||
sep=; !.=0 /*X can't be > length(@0abcs). */
|
||||
@abc = 'abcdefghijklmnopqrstuvwxyz'; parse upper var @abc @abcU
|
||||
@abcS= @abcU || @abc; @0abcS=123456789 || @abcS
|
||||
z= /*set Z to a null value. */
|
||||
do i=1 for x /*build a list of (perm) symbols.*/
|
||||
_=p(word(uSyms,i) p(substr(@0abcS,i,1) k)) /*get or gen a symbol.*/
|
||||
if length(_)\==1 then sep=',' /*if not 1st char, then use sep. */
|
||||
if length(_)\==1 then sep=',' /*if not 1st char, then use SEP. */
|
||||
z=z || sep || _ /*append it to the symbol list. */
|
||||
end /*i*/
|
||||
|
||||
if sep\=='' then z=strip(z,'L', ",")
|
||||
!.z=1; #=1; times=!(x)%!(x-y); q=z; s=1; w=max(length(z),length('permute'))
|
||||
#=1
|
||||
if sep\=='' then z=strip(z, 'L', ",") /*strip leading commas from Z. */
|
||||
!.z=1; q=z; s=1; times=!(x)%!(x-y) /*calculate TIMES using factorial*/
|
||||
w=max(length(z),length('permute')) /*maximum width of Z and PERMUTE.*/
|
||||
say center('permutations for ' x ' with ' y "at a time",60,'═')
|
||||
say
|
||||
say 'permutation' center("permute",w,'─') 'sign'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue