<< Prev | - Up - | Next >> |
Oz provides expressions to describe values. There may be many alternative expressions describing the same value. We start with variable free expressions that determine some value completely.
Integers are described as 0, 1, ~1, 2, 3
etc and floats by 0.0, 1.0, ~1.1
etc.
Atoms are described by words starting with lower case letter like thisIsAnAtom
or by a word in backwards quotes like 'case'
, 'true'
and 'ThisIsAnAtom'
.
The Booleans and the unit are described by the keywords true
, false
, unit
.
Typical description for tuples and records are the following:
plus(5 times(5 ~10))
address(street:'Talstrasse'
name:unit(first:hans
second:kamp))
det(phon:a number:singular)
In the first tuple, we have left out the features; it's a syntactically suggared version of plus(1:5
.
2:times(1:5 2:~10))
The values of a record at some feature can be selected by using the selection function that is denoted by a dot. For instance, the atom singular
is described by the expression
det(phon:a number:singular).number
Typical descriptions of lists are: 1|2|3|nil
, [1 2 3]
, and nil
. Note however that [ ]
does not describe the empty list!
A description of a procedure computing the square function is:
fun{$ X} X*X end
The symbol $
simply means that this procedure is anonymous, i.e. is not yet given a name. The syntax for the application of procedures uses curly brackets. For instance, the number 9
is described by the following application whose evaluation computes the square of 3
:
{fun{$ X} X*X end 3}
<< Prev | - Up - | Next >> |