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
. The objects may be of different
types, though a well-designed algorithm will likely create lists of
objects of a single type.
In particular, a list may contain other lists. The empty list is
We use square brackets to index into a list. If
is a non-empty
is an integer (between 1 and
-th component of
; indexes start from 1.
contains sublists, we can write
(see the example below).
Lists are often used to build structured objects of type
/**/ use R ::= QQ[t,x,y,z];
/**/ L := [34*x+y^2, "a string", , [True, False]]; -- a list
/**/ L; -- the 1st component
/**/ L; -- The 4th component is a list, itself;
/**/ L; -- its 1st component;
/**/ L[4,1]; -- the same.
/**/ [1,"a"]+[2,"b"]; -- NOTE: one may add lists if their components
[3, "ab"] -- are compatible (see "Algebraic Operators").
/**/ L := [x^2-y, t*y^2-z^3];
/**/ I := ideal(L);
ideal(x^2 -y, t*y^2 -z^3)