[Newbies] Re: Another extension proposal -> subsets
nicolas cellier
ncellier at ifrance.com
Fri Jul 25 09:33:54 UTC 2008
cdrick <cdrick65 <at> gmail.com> writes:
>
> Yes.. Nico's solution is lot faster...
>
> set := #(1 2 3 4 5) asSet.
> [ set subsets "mine"] timeToRun ." 1"
> [ set subsets2 "Zulk first" ] timeToRun. " 8"
> [ set subsets4 "Nicolas"] timeToRun. " 1"
> [ set subsets5 "Zulk"] timeToRun. " 2"
>
> set := (1 to: 10) asSet.
> [ set subsets ] timeToRun . " 46"
> [ set subsets4 ] timeToRun. " 18"
> [ set subsets5 ] timeToRun." 114"
>
> set := (1 to: 15) asSet.
> [ set subsets ] timeToRun ." 2484"
> [ set subsets4 ] timeToRun. " 1598"
> [ set subsets5 ] timeToRun." 12493"
>
> Nicolas won ;) So maybe we can add this one and rename the
> combinations:atATime: ?
>
> Cédrick
>
He, press ALT-v to get versions of #combinations:atATimeDo: and thanks tk!
I like bit sift solution too for it's simplicity.
The problem is that it will iterate p times for creating each subset of size p.
#combinations:atATimeDo: does not. It is building subsets in parallel.
The required copy does an iteration though, but in a primitive!
Hence the difference...
Nicolas
More information about the Beginners
mailing list