up
previous
next
Introduction to Lists
A CoCoA list is a sequence of CoCoA objects between brackets. 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
, VECTOR
, IDEAL
,
and MODULE
.
example
Use R ::= Q[t,x,y,z];
L := [34x+y^2,"a string",[],[TRUE,FALSE]]; -- a list
L[1]; -- the list's 1st component
y^2 + 34x
-------------------------------
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,ty^2-z^3];
I := Ideal(L);
I;
Ideal(x^2 - y, ty^2 - z^3)
-------------------------------