Power set: Difference between revisions

m
→‎{{header|REXX}}: changed the "set" variable name to '''S'''. -- ~~~~
(→‎{{header|REXX}}: added the REXX language. -- ~~~~)
m (→‎{{header|REXX}}: changed the "set" variable name to '''S'''. -- ~~~~)
Line 1,704:
=={{header|REXX}}==
<lang rexx>/*REXX program to display a power set, items may be anything (no blanks)*/
parse arg setS /*let user specify the itemsset. */
if set=S='' then setS='one two three four' /*None specified? Use default*/
N=words(setS) /*number of items in the list.*/
ps='{}' /*start with a null power set.*/
do chunk=1 for N /*traipse through the items. */
Line 1,717:
exit /*stick a fork in it, we done.*/
/*─────────────────────────────────────$COMBN subroutine────────────────*/
combN: procedure expose $ setS; parse arg x,y; $=
!.=0; base=x+1; bbase=base-y; ym=y-1; do p=1 for y; !.p=p; end
do j=1; L=
do d=1 for y; _=!.d; L=L','word(setS,_); end
$=$ '{'strip(L,'L',",")'}'
!.y=!.y+1; if !.y==base then if .combU(ym) then leave