[Squeak] Newbie permutations
Markus Gaelli
gaelli at emergent.de
Tue Apr 9 07:54:36 UTC 2002
>
> 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
|