Lists play a special role in the GCL. Variables can be created to
contain lists in the same fashion as for any other data type:
The built in function \verb+List[x,n]+ can be used to
create a list of length \verb+n+ all of whose elements have the value
\verb+x+. For numeric data types, a third parameter for
List
allows each successive entry to be incremented.
GCL1:= << List["Help",3]
{ "Help", "Help", "Help" }
GCL2:= << List[List[0,3],3]
{ { 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 } }
GCL3:= << List[0/1, 5, 1/4]
{ 0, 1/4, 1/2, 3/4, 1 } |
Lists of any data type can be created with
List. So if
\verb+n+ is a normal form game, then \verb+List[n,5]+ is a list of five
copies of \verb+n+.
The function NthElement can be used
to get \verb+n+th element of the list, \verb+list+. This function has
two short forms, list[[n]] and list_n.
Since the
function returns the \verb+n+th element of the list, it can be used
recursively to get the elements of nested lists. So \verb+list_i_j+
returns the \verb+j+th element of the \verb+i+th element of
\verb+list+. Also, since \verb+list+ is passed by reference, the
function can be used to modify the corresponding element of a list.
Thus, you can constuct your own 3-by-3 identity matrix as
follows:
GCL1:= list:=List[List[0,3],3]
GCL2:= list_1_1:=list_2_2:=list_3_3:=1;
GCL3:= << list
{ { 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 } } |