Hi Mike and Travis, Thank you very much for your replies.
Mike, your code snippet is unfortunately not what I am looking for. Sorry for being unclear. I'd like to construct the set of tuples of all lengths, not just tuples of length up to a certain bound. Travis, the FreeMonoid looks very promising. Word of arbitrary length in the set S should work just as well as tuples. I'll experiment with that a little and report back. Cheers, Simon On Friday, April 22, 2016 at 12:46:53 PM UTC+10, Travis Scrimshaw wrote: > > Hey Simon, > You might want to use FreeMonoid(index_set=S) as your basis indexing > set. Although you will need 7.2.beta5 to do the iteration: > > sage: S = (1,2) > sage: F = FreeMonoid(index_set=S) > sage: it = iter(F) > sage: [next(it) for _ in range(10)] > [1, F[1], F[2], F[1]*F[2], F[2]^2, F[1]^2, F[2]*F[1], F[1]^2*F[2], F[2]^2* > F[1], F[1]^3] > sage: [next(it).to_word_list() for _ in range(10)] > [[], [1], [2], [1, 2], [2, 2], [1, 1], [2, 1], [1, 1, 2], [2, 2, 1], [1, 1 > , 1]] > sage: F([[1,4],[2,1],[1,1],[2,3]]) > F[1]^4*F[2]*F[1]*F[2]^3 > > This works for any set S, but the iterator will only work for finite sets > S. However, perhaps there could be some additional functionality for > IndexedFreeMonoid that could be added to make it work with your use case. > > Best, > Travis > > -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-combinat-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-combinat-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-combinat-devel. For more options, visit https://groups.google.com/d/optout.