[Squeak] Newbie permutations
Torge Husfeldt
jean-jacques.gelee at gmx.de
Tue Apr 9 09:40:14 UTC 2002
IIRC there is another annoyance loosely related in the collections
hierarchy:
Dictionary>>copy does not copy the associations.
Now that a dictionary consist of associations is a pure implementation
detail and no code should rely on this fact.
Just my 2centimes
> >
> > Aha. Since this threw me for a second, I should probably explain -
> > permutationsDo: is reusing the same array for each permutation. Hence
> > the
> > need for the #copy in the correct version,
> >
> > #(1 3 5) permutationsDo: [:each | foo add: each copy]
> >
> > Is there a widespread convention at work here, or is this just a
> > pecularity of the implementation of that particular method?
>
> I know at least about one other method, which is quite similar and
> where you have to take care to copy each element.
>
> SequencableCollection >> asDigitsToPower: anInteger do: aBlock
> (then also
> SequencableCollection >> asDigitsAt: 1 in: aCollection do: aBlock)
>
> Markus
>
>
More information about the Squeak-dev
mailing list
|