+1 for s.card() but I would suggest also making s.cardinality() an alias for it.
didier On Wed, Feb 25, 2009 at 5:43 PM, Florent Hivert <florent.hiv...@univ-rouen.fr> wrote: > > Dear All, > > We working in combinat have a problem of naming convention which is likely to > concern everyone in sage. As you can guess, in combinatorics we like to count > sets an iterate through them. So we designed some objects called for now > CombinatorialClass which represent a finite or countable set sorted in a > particular order (eg the permutations of 4 in the lexicographic order). Such a > set can be counted and iterated through. > > My question is the following: we are looking for a good name for the method > which returns the number of element of a set S. > > Note that we will widely implement this method for sets which can be of any > combinatorial use, including for example the sets of natural numbers N, the > finite rings and fields Z/pZ, any finite groups. So we want the name to be > consistent through all sage. > > Until now we use len(S) but this is bad because in python specification > __len__ must returns a python int, whereas we want to have an arbitrary large > integer and even +infinity: > > object.__len__(self) > Called to implement the built-in function len(). Should return the > length of the object, an integer >= 0. > > We were going to use s.count() until someone pointed out than there is a > collision with a standard python methods for list. > > s.count(x) > return number of i‘s for which s[i] == x > > Other suggestion are: > - s.length() : this is more ore less coherent with data structures but > seems to me to be too far from the mathematical thinking; > - s.cardinality() : we don't like it because this is too long. Remember that > we will type it every two lines; > - s.card() is currently my favorite... > > Sorry for asking a question and giving at the same time my opinion. But I'd > like this decision to be taken as soon as possible: there are a bunch of patch > waiting only this answer... > > If you also have any suggestion for CombinatorialClass which was good in MuPAD > when (object oriented) class where called domains but which is now too much > confusing... Thanks for your help and comments. > > Cheers, > > Florent > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---