up previous next
 2.6.1 Introduction to RECORD
A record is a data type in CoCoA representing a list of bindings of the form name to object.

 Example
 ```/**/ use R ::= QQ[x,y,z]; /**/ P := record[ I := ideal(x,y^2-z), F := x^2 + y, Misc := [1,3,4]]; /**/ P.I; ideal(x, y^2 -z) /**/ P["I"]; ideal(x, y^2 -z) /**/ P.Misc; [1, 3, 4] /**/ P.Misc[2]; 3 /**/ P.Date := "1/1/98"; /**/ indent(P); record[ Date := "1/1/98", F := x^2 +y, I := ideal(x, y^2 -z), Misc := [1, 3, 4] ] /**/ P["Misc",3]; -- equivalent to P.Misc[3] 4 ```
Each entry in a record is called a field. Note that records are open in the sense that their fields can be extended, as shown in the previous example. At present, there is no function for deleting fields from a record, one must rewrite the record, selecting the fields to retain:

 Example
 ```/**/ P := record[A := 2, B := 3, C := 5, D := 7]; /**/ Q := record[]; Foreach F In Fields(P) Do If F <> "C" Then Q[F] := P[F]; EndIf; EndForeach; /**/ P := Q; /**/ P; record[A := 2, B := 3, D := 7] ```