Power set: Difference between revisions

m
(→‎{{header|REXX}}: Reformat and use a better /readable) version of combinations)
 
(4 intermediate revisions by 3 users not shown)
Line 3,664:
End
Exit
comb: Procedure
/***********************************************************************
* Returns the combinations of size digits out of things digits
Line 3,670:
1 2/ 1 3/ 1 4/ 2 3/ 2 4/ 3 4 /
***********************************************************************/
comb: Procedure
Parse Arg things,size
n=2**things-1
list=''
Do u=1 toTo n
co=combinations(u)
If co>'' Then
list=list '/' combinations(u)
End
Return substr(space(list),2) '/' /* remove leading / */
 
combinations: Procedure Expose things size
Line 4,624 ⟶ 4,623:
 
We therefore use lists to represent sets which works fine here.
<syntaxhighlight lang="ecmascriptwren">import "./perm" for Powerset
 
var sets = [ [1, 2, 3, 4], [], [[]] ]
2,120

edits