I'm afraid that's not working. Appartently len has been removed and replaced with cardinality(). Thanks for the tip about ".[tab]". However I still seem to be rather stuck:
If I run this code: Columns=3 Rows=3 RowVector=[2,3,2] ComSet=[] for j in range(Columns): C=Combinations(range(Rows),RowVector[j]) ComSet.append(C.list()) show(ComSet) ComSet then appears as: [[[0,1],[0,2],[1,2]],[[0,1,2]],[[0,1],[0,2],[1,2]]] which is what I require. If I then use ".[tab]" on ComSet I get various options, none of which include "len" and or "cardinality". The only option that looks relatively right would be "count" but I can't seem to find any help on that command and can't seem to use it correctly. If I use .[tab] on any element of ComSet, for example on [[0,1],[0,2],[1,2] ] I seem to get a similar problem (and len does not appear as an option): Defining: C=[[0,1],[0,2],[1,2]] and then C.[tab] gives me the same options as before (i.e. count which I don't seem to be able to find any help for). If however I define C in a different manner: C=Combinations(range(3),2) then C.[tab] does indeed give me cardinality. I am obviously missing something simple. Is there a straightforward way to obtain the length of a set? Any further help would be greatly appreciated, Vince On 2 September 2011 12:01, Robert Bradshaw <rober...@math.washington.edu>wrote: > On Fri, Sep 2, 2011 at 3:44 AM, Vince <vincent.kni...@gmail.com> wrote: > > Dear all, > > > > If I have a list, how do I obtain the cardinality of the list, the > > command Cardinality() doesn't seem to always work. For example, the > > following code produces a set ComSet of sets of combinations. > > > > Rows=3 > > RowVector=[2,3,2] > > ComSet=[] > > for j in range(Columns): > > C=Combinations(range(Rows),RowVector[j]) > > ComSet.append(C.list()) > > show(ComSet) > > What's Columns? > > > However using Cardinality() on ComSet does not seem to work: > > > > ComSet.Cardinality() > > > > Basically I am looking for the mathematica command "Length". > > > FYI, most Python and Sage commands start with a lower case. In this > case, however, what you're looking for is len(ComSet). If you have an > object x, type x-dot-tab to see what methods it supports. > > > Furthermore how would I be able to map that command on to the elements > > of ComSet? > > Use "list comprehensions" (it's a Python thing). > > sage: L = [[1, 2, 3], [4, 5]] > sage: [len(a) for a in L] > [3, 2] > > -- > To post to this group, send email to sage-support@googlegroups.com > To unsubscribe from this group, send email to > sage-support+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-support > URL: http://www.sagemath.org > -- Dr Vincent Knight Cardiff School of Mathematics Senghennydd Road, Cardiff CF24 4AG (+44) 29 2087 5548 www.vincent-knight.com @drvinceknight <http://twitter.com/#!/drvinceknight> Skype: drvinceknight -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org