Collection Permutations/Combinations code?

Joshua 'Schwa' Gargus schwa at cc.gatech.edu
Fri May 23 04:09:38 UTC 2003


On Thu, May 22, 2003 at 08:57:08PM -0700, Ned Konz wrote:
> On Thursday 22 May 2003 08:30 pm, Joshua 'Schwa' Gargus wrote:
> > Does anyone have code that does something like:
> >
> > aCollection choose: 3 do: [:array | ...]
> >
> > where each possible unordered collection of 3 elements (ie:
> > "n-choose-k", where n is the size of aCollection and k is here 3)
> > is chosen from aCollection and passed as the argument to the block?
> 
> You mean like
> 
> SequenceableCollection>>combinations:atATimeDo:

Exactly!  Thanks.

> 
> there's also permutationsDo:

This one I knew about, but doesn't do quite what I want.

Thanks again,
Joshua

> 
> -- 
> Ned Konz
> http://bike-nomad.com
> GPG key ID: BEEA7EFE
> 



More information about the Squeak-dev mailing list