[Newbies] Re: Another extension proposal -> subsets
cdrick65 at gmail.com
Thu Jul 24 17:46:22 UTC 2008
> Didn't check #combinations:* implementation, does it avoid #includes: ?
I think so. It calls #combinationsAt:in: after: do: wich is recursive.
>> I'd still prefer #combinationsSize:do: instead of
> +1 but it looks alt-w friendly already (like #detectSum: looks ;)
Funny to see it was probably the original name. See the comment of
#combinationsAt:in: after: (last line)
"Choose k of N items and put in aCollection. jj-1 already chosen.
Indexes of items are in numerical order, to avoid the same combo being
used twice. In this slot, we are allowed to use items in self indexed
by nn+1 to self size. nn is the index used for position jj-1."
"(1 to: 6) combinationsSize: 3 do: [:each | Transcript cr; show: each
>>> How about naming
>>> ^ self asSet powersetInto: (Set new: (2 raisedTo: self size))
>>> with Set>>#powersetInto: and putting that into the next release.
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
More information about the Beginners