Hi I'm looking for a method that given #(1 2 3) returns #( #(1) #(2) #(3) #(1 2) #(2 3) #(1 3) #( 1 2 3)) Stef
Hi, this solution is not exactly beautiful, but it works: | input output | input := #(1 2 3). output := Array streamContents: [ :stream | 1 to: input size do: [ :take | input combinations: take atATimeDo: [ :combination | stream nextPut: combination copy ] ] ]. output inspect Michal On 28.4.2015 20:02, stepharo wrote:
Hi
I'm looking for a method that given #(1 2 3) returns #( #(1) #(2) #(3) #(1 2) #(2 3) #(1 3) #( 1 2 3))
Stef
Hi michal Thanks! Stef Le 28/4/15 21:07, Michal Balda a écrit :
Hi, this solution is not exactly beautiful, but it works:
| input output |
input := #(1 2 3).
output := Array streamContents: [ :stream | 1 to: input size do: [ :take | input combinations: take atATimeDo: [ :combination | stream nextPut: combination copy ] ] ].
output inspect
Michal
On 28.4.2015 20:02, stepharo wrote:
Hi
I'm looking for a method that given #(1 2 3) returns #( #(1) #(2) #(3) #(1 2) #(2 3) #(1 3) #( 1 2 3))
Stef
The comment of the method combinationsAt: jj in: aCollection after: nn do: aBlock refers to (1 to: 6) combinationsSize: 3 do: [:each | Transcript cr; show: each printString] but this method does not exist Le 28/4/15 20:02, stepharo a écrit :
Hi
I'm looking for a method that given #(1 2 3) returns #( #(1) #(2) #(3) #(1 2) #(2 3) #(1 3) #( 1 2 3))
Stef
participants (3)
-
Michal Balda -
Sergio Fedi -
stepharo