Anonymous user
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
if
N=words(
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 $
!.=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(
$=$ '{'strip(L,'L',",")'}'
!.y=!.y+1; if !.y==base then if .combU(ym) then leave
|