I would like to generate compositions in reverse lex order. However, I get:

_______________________________________________________________

sage: C = reversed(Compositions(4))
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/jyt/monge/TEX/QSCHUR/<ipython console> in <module>()

/home/jyt/src/sage-5.4.1/local/lib/python2.7/site-packages/sage/combinat/combinat.py
 
in __len__(self)
    972             AttributeError: __len__ has been removed; use 
.cardinality() instead
    973         """
--> 974         raise AttributeError, "__len__ has been removed; use 
.cardinality() instead"
    975 
    976     def count(self):

AttributeError: __len__ has been removed; use .cardinality() instead

___________________________________________________________________________

Of course, I can do
 ___________________________________________________________________________
sage: C = list(reversed(Compositions(4).list()))
sage: C
[[4], [3, 1], [2, 2], [2, 1, 1], [1, 3], [1, 2, 1], [1, 1, 2], [1, 1, 1, 1]]
____________________________________________________________________________

but isn't it ugly? I need the outer list to access the items:
____________________________________________________________________________
sage: C = reversed(Compositions(4).list())
sage: C[3]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/jyt/monge/TEX/QSCHUR/<ipython console> in <module>()

TypeError: 'listreverseiterator' object has no attribute '__getitem__'
_____________________________________________________________________________
with Compositions:
_____________________________________________________________________________
sage: c=Compositions(4)
sage: c[3]
[1, 3]


-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sage-combinat-devel/-/0cLLQFZlpdsJ.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to