Many thanks for this. Apologies for incomplete code: Columns=3.

Vince
On 2 Sep 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

-- 
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

Reply via email to