[Squeak] Newbie permutations
scott.wallace at squeakland.org
Tue Apr 9 07:12:28 UTC 2002
There's probably at least one cool way using streams to do this, and
at least one other cool way using #inject:into:; but the following
naive approach works painlessly:
Foo _ OrderedCollection new.
#(1 3 5) permutationsDo: [:each | Foo add: each].
At 11:52 PM -0700 4/8/02, Michael Grant wrote:
>I don't know if this is the correct forum but I can
>find no other mailing list so here goes (at 3:00am):
>I need a Smalltalk 'AHA!' moment.
>The following expression (Squeak 3.0)writes the
>#(1 3 5) to the Transcript as expected:
>#(1 3 5) permutationsDo: [:each | Transcript cr;
> show: each
>However, I can not figure out how to save the
>permutations to a
>variable, say 'Foo', with Foo having the value:
> #(#(1 3 5) #(1 5 3) #(3 1 5)...)
>My efforts have typically ended up as #(nil nil ...),
>or an error, or
>something like #(#(1 3 5) #(1 3 5) #(1 3 5) ...)
>Can someone enlighten me? It must be simple, but...
>P.S. If there is a more appropriate list for newbie
>please let me know.
>Do You Yahoo!?
>Yahoo! Tax Center - online filing with TurboTax
More information about the Squeak-dev