type element_record = record [ name : array [ character ]; number : integer; weight : real ] type atomic_table = array [ element_record ];When creating items of record types, we specify the matched pairs of field names and contents, in the order given in the type definition. Here are examples:
let hydrogen := record element_record [ name: "Hydrogen"; number: 1; weight: 1.0 ]; helium := record element_record [ name: "Helium"; number: 2; weight: 4.0 ]; element_115 := record element_record [ name: ""; number: 115; weight: -999.999]; column1 := array atomic_table [ 1: hydrogen, helium, element_115 ] in hydrogen, helium, element_115, column1 end letHere we see three records being created, each of which has its type, element_record, specified along with it. This is sometimes optional, but it's a good practice to adopt, nonetheless, as it helps clarify the code to human readers. The first two records, hydrogen and helium have their field names and values specified in the order given in the original declaration, and with reasonable values. The field names must be paired with the field values, with a colon separating each name and value, and a semicolon separating the pairs, as in the definition of the type. In the third record, element_115, we see and empty string used for the name and a negative value for the weight, used as flag values. This is still a legal record, since all the fields are specified in order and with correct types.
The fourth item created and returned above is an array named column1 of type atomic_table. We will see more about creating arrays in the next section.