up previous next
 2.5.1 Introduction to LIST
A CoCoA list is a sequence of CoCoA objects between square brackets. See also List Constructors.

In particular, a list may contain other lists. The empty list is [] . If L is a list and N is an integer, then L[N] is the N -th component of L .

If L contains sublists, then L[N_1, N_2,...,N_s] is shorthand for L[N_1][N_2]...[N_s] (see the example below).

Lists are often used to build structured objects of type MAT , MODULEELEM , IDEAL , and MODULE .

 Example
 ```/**/ Use R ::= QQ[t,x,y,z]; /**/ L := [34*x+y^2, "a string", [], [True, False]]; -- a list /**/ L[1]; -- the 1st component y^2 +34*x /**/ L[2]; a string /**/ L[3]; [ ] /**/ L[4]; -- The 4th component is a list, itself; [true, false] /**/ L[4][1]; -- its 1st component; true /**/ L[4,1]; -- the same. true /**/ [1,"a"]+[2,"b"]; -- NOTE: one may add lists if their components are [3, "ab"] -- compatible (see "Algebraic Operators"). /**/ L := [x^2-y, t*y^2-z^3]; /**/ I := ideal(L); /**/ I; ideal(x^2 -y, t*y^2 -z^3) ```