green351 wrote:
> Hi.  I have the following problem: consider the following list of
> compositions and its cartesian product with itself.
> 
> C83=Compositions(8, length=3);
> cp=CartesianProduct(C83,C83)
> 
> I want to remove certain elements from this set/list and then to count
> the elements left.  For example I want to remove the element [[1,1,6],
> [1,2,5]] and in general for [[a,b,c],[d,e,f]], I want to remove it if
> a=d=1 OR b=e=1 Or c=f=1.  There are other things I want to remove but
> I think if I figure out the correct syntax for the above I could
> probably figure the rest out. How would I do this?
> 


You could also use list comprehensions to construct a list of elements 
that you want:

[e for e in cp if not ((e[0][0]==1 and e[1][0]==1) or (e[0][1]==1 and 
e[1][1]==1) or (e[0][2]==1 and e[1][2]==1))]


Jason


--~--~---------~--~----~------------~-------~--~----~
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
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to