Download Learning Timed χ 1.0 - Manufacturing Networks Wiki

Transcript
Chapter 11
Record tuples
In this chapter we introduce the compound data type record tuple and a number of commonly used applications.
11.1
A record tuple
A record tuple is a variable that has a fixed number of elements. Each element can be of a
different type. A tuple with the elements 12 and 3.14 is denoted as (12, 3.14). This tuple is
of type (nat,real). The tuple (2.1, “part”, +3) is of type (real,string,int). We use projection
to obtain an element from a record tuple. Projection is denoted by a dot. The first element
in a tuple has index 0. Some examples are:
(2.1, “part”, +3).0
(2.1, “part”, +3).1
(2.1, “part”, +3).2
(12, 3.14).1
=
=
=
=
2.1
“part”
+3
3.14
If a record tuple is indexed outside its scope, e.g. (1, 2, 3).3, an error is reported and the
simulation is aborted.
Other compound data types may be used in a record tuple. For instance, we can have a
record tuple xt of lists or a record tuple yt that contains a record tuple.
xt = ([0, 1, 2, 3, 4], [9, 8, 7, 6, 5], [true, true, false, false])
yt = ([0, 1, 2, 3, 4], 1.23, (0, true))
The type of xt is ([nat],[nat],[bool]). The type of yt is ([nat],real,(nat,bool)). The following
equations hold:
xt.0 ++xt.1 = [0, 1, 2, 3, 4, 9, 8, 7, 6, 5]
hd(xt.0) = 0
87