But this doesn't get 1-1, 2-2 or 3-3. I had tried something like that use #reverse on each combination, but #combinations does not generate -duplicates- from the number sequences.
On Tue, Jan 5, 2010 at 12:16, Henrik Johansen <henrik.s.johan...@veloxit.no>wrote: > On Jan 5, 2010, at 5:19 32PM, John Toohey wrote: > > > Hi, > > I'm trying to generate the permutations of a sequence of numbers. I've > found # permutationsDo: aBlock, but this generated the permutation of the > entire sequence. I want to do it in groups of 2. The #combinations: > anInteger atATimeDo: aBlock method does what I need for combinations, but I > cannot find the equivalent for permutations. Does something like this exist > in the standard library, or in an external package. > > > > -- > > -JT > > How about: > #(1 2 3 4) combinations: 2 atATimeDo: [:array | array permutationsDo: > [:each | Transcript show: each printString; cr]] ? > > Cheers, > Henry > > > _______________________________________________ > Pharo-project mailing list > Pharo-project@lists.gforge.inria.fr > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > -- -JT
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project