Anonymous user
Power set: Difference between revisions
m
→{{header|REXX}}: added/changed whitespace and comments, split a compound statement.
Not a robot (talk | contribs) (Add APL) |
m (→{{header|REXX}}: added/changed whitespace and comments, split a compound statement.) |
||
Line 3,362:
say right(k, w) word(@, k) /*display a single combination to term.*/
end /*k*/
exit
/*──────────────────────────────────────────────────────────────────────────────────────*/
combN: procedure expose S; parse arg x,y; base= x + 1; bbase= base - y
!.= 0
do p=1 for y; !.p= p
end /*p*/
$= /* [↓] build powerset*/
do j=1;
do d=1 for y; L= L','word(S,
end /*j*/
return strip($) /*return with a partial power set chunk*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 3,379 ⟶ 3,380:
p= !.d
do u=d to y; !.u= p + 1; if !.u==bbase+u then return .combU(u-1)
p= !.u /* ↑ */
end /*u*/ /*recurse──►───┘ */
return 0</lang>
{{out|output|text= when using the default input:}}
|