[Squeak] Newbie permutations
Andrew C. Greenberg
werdna at mucow.com
Tue Apr 9 19:19:36 UTC 2002
Right. that is because the parameter is simply the same array being
manipulated in situ. Hence, you have an array of references all to the
same object. The following works for me
Array streamContents: [:s |
#(1 3 5) permutationsDo: [:each | s nextPut: each copy]]
Alternatively, you can use the code below, just insert the message copy
after each.
On Tuesday, April 9, 2002, at 03:15 AM, Duane Maxwell wrote:
>> | foo |
>> foo := OrderedCollection new.
>> #(1 3 5) permutationsDo: [:each | foo add: each].
>>
>> Does that do it for you?
>
> No, unfortunately this gives:
>
> an OrderedCollection ( #(1 3 5) #(1 3 5) #(1 3 5) #(1 3 5) #(1 3 5)
> #(1 3
> 5) )
>
> ...which is what probably prompted the question.
>
> -- Duane
>
>
More information about the Squeak-dev
mailing list
|