up previous next
len

the length of an object

Syntax
len(E:STRING or LIST or RINGELEM):INT

Description
This function returns the length of an object, as summarized in the table below:
      ----------------------------------------------
     | type   | length                              |
     -----------------------------------------------|
     | INT    | 1                                   |
     | LIST   | number of items in the list         |
     | MODULE | length of Gens(E)                   |
     | POLY   | number of monomials                 |
     | VECTOR | number of components                |
      ----------------------------------------------
               The operator 
    len  


Example
/**/  Use R ::= QQ[x,y];
/**/  L := ["a",2,3,[4,5]];
/**/  len(L);
4

/**/  len(L[1]);
1

/**/  len(L[4]);
2

/**/  F := x^2 + x*y + y^2 + x*y^4;
/**/  len(F);
4

/**/  NumTerms(F); --> is the same of len(F)!
4

/**/  len((x+y) - (x*y/x));
1

/**/  A := mat([[1,2],[3,4],[5,6]]);
/**/  len(A);
ERROR: len(Matrix) not allowed, use NumRows(matrix) instead

/**/  NumRows(A); 
3
The function size returns the amount of memory used by the object.
See Also