03.08.2013 Views

PTOLEMY II - CiteSeerX

PTOLEMY II - CiteSeerX

PTOLEMY II - CiteSeerX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

that match. Thus, for example,<br />

{foodCost=40, hotelCost=100} + {foodCost=20, taxiCost=20}<br />

yields the result<br />

{foodCost=60}<br />

Expressions<br />

You can think of an operation as a set intersection, where the operation specifies how to merge the values<br />

of the intersecting fields. You can also form an intersection without applying an operation. In this<br />

case, using the intersect() function, you form a record that has only the common fields of two specified<br />

records, with the values taken from the first record. For example,<br />

>> intersect({a=1, c=2}, {a=3, b=4})<br />

{a=1}<br />

Records can be joined (think of a set union) without any operation being applied by using the<br />

merge() function. This function takes two arguments, both of which are record tokens. If the two<br />

record tokens have common fields, then the field value from the first record is used. For example,<br />

merge({a=1, b=2}, {a=3, c=3})<br />

yields the result {a=1, b=2, c=3}.<br />

Records can be compared, as in the following examples:<br />

>> {a=1, b=2}!={a=1, b=2}<br />

false<br />

>> {a=1, b=2}!={a=1, c=2}<br />

true<br />

Note that two records are equal only if they have the same field labels and the values match. As with<br />

scalars, the values match irrespective of type. For example:<br />

>> {a=1, b=2}=={a=1.0, b=2.0+0.0i}<br />

true<br />

The order of the fields is irrelevant. Hence<br />

>> {a=1, b=2}=={b=2, a=1}<br />

true<br />

Moreover, record fields are reported in alphabetical order, irrespective of the order in which they are<br />

106 Ptolemy <strong>II</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!