Hi --
Is there a standard Smalltalk way to enumerate the possible permutations and combinations of a collection of collections? I'm not having any luck googling for an example or mention of a class or package to use. I'm trying to minimize a non linear cost function and want to calculate the set of costs. The collection of collections can have any number greater than two collections in it and those collections are of varying size. Thanks Paul _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On 12.03.2010, at 15:27, Paul DeBruicker wrote:
> > Hi -- > > Is there a standard Smalltalk way to enumerate the possible permutations > and combinations of a collection of collections? I'm not having any > luck googling for an example or mention of a class or package to use. Type "permut" somewhere. Select, press Cmd-Shift-W. You'll see a few candidates :) - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Paul DeBruicker
Ahh. Thanks. Thats helpful.
An illustration of what I want is: |w x y z | w:=OrderedCollection with: 'A' x:=OrderedCollection with: 'a' with: 'b' with: 'c' with: 'd'. y:=OrderedCollection with: '1' with: '2' with:'3'. z:=OrderedCollection with: x with: y. from z I want to get #('A' 'a' '1') #('A' 'a' '1') #('A' 'a' '1') #('A' 'a' '1') #('A' 'a' '1') #('A' 'a' '1') #('A' 'a' '1') #('A' 'a' '1') #('A' 'a' '1') #('A' 'a' '1') #('A' 'a' '1') #('A' 'a' '1') #('A' 'a' '1') _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Sorry. I hit send inadvertently.
An illustration of what I want is: |w x y z | w:=OrderedCollection with: 'A' x:=OrderedCollection with: 'a' with: 'b' with: 'c' with: 'd'. y:=OrderedCollection with: '1' with: '2' with:'3'. z:=OrderedCollection with: w with: x with: y. from z I want to get #('A' 'a' '1') #('A' 'b' '1') #('A' 'c' '1') #('A' 'd' '1') #('A' 'a' '2') #('A' 'b' '2') #('A' 'c' '2') #('A' 'd' '2') #('A' 'a' '3') #('A' 'b' '3') #('A' 'c' '3') #('A' 'd' '3') The permut* functions you helped me find seem to make the permutations of the collections, but not the contents of the collections. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On 12.03.2010, at 16:28, Paul DeBruicker wrote:
> > Sorry. I hit send inadvertently. > > > > > An illustration of what I want is: > > |w x y z | > w:=OrderedCollection with: 'A' > x:=OrderedCollection with: 'a' with: 'b' with: 'c' with: 'd'. > y:=OrderedCollection with: '1' with: '2' with:'3'. > z:=OrderedCollection with: w with: x with: y. > > from z I want to get > #('A' 'a' '1') > #('A' 'b' '1') > #('A' 'c' '1') > #('A' 'd' '1') > #('A' 'a' '2') > #('A' 'b' '2') > #('A' 'c' '2') > #('A' 'd' '2') > #('A' 'a' '3') > #('A' 'b' '3') > #('A' 'c' '3') > #('A' 'd' '3') > > The permut* functions you helped me find seem to make the permutations > of the collections, but not the contents of the collections. Now that looks like simple nested iterations, not permutations: Array streamContents: [:s | #('A') do: [:a | #('a' 'b' 'c' 'd') do: [:b | #('1' '2' '3') do: [:c | s nextPut: {a. b. c}]]]] - Bert - _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |