Hello,
On Tue, Nov 16, 2010 at 12:03 AM, Rolandb <[email protected]> wrote:
> 3) I could not find a Sage standard function to deliver this output.
> There are so many functions around...
> Is there such a function? An iterator is even better. N.B.: The above
> example "splits" can easily transformed to an iterator, but that is
> not the issue.
SetPartitions is what you want.
sage: S = SetPartitions(range(4),2); S
Set partitions of [0, 1, 2, 3] with 2 parts
sage: S.list()
[{{1, 2, 3}, {0}}, {{0, 2, 3}, {1}}, {{2}, {0, 1, 3}}, {{0, 1, 2},
{3}}, {{2, 3}, {0, 1}}, {{1, 3}, {0, 2}}, {{1, 2}, {0, 3}}]
sage: it = iter(S)
sage: it.next()
{{1, 2, 3}, {0}}
sage: S.cardinality()
7
--Mike
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org