Oz values are classified as shown in the type hierarchy in
Figure . For every type
in Oz there is a corresponding module.
Modules corresponding to types in The Definition of Kernel Oz
[11]
are
shaded dark in the figure and modules
corresponding to derived types are shaded light.
The following sections describe the modules associated with the types in
Figure
.
Figure: Classification of Values in Oz
The module Value contains the procedure Det and comparison procedures, i.e. procedures to compare integers with integers, floats with floats and atoms with atoms. Comparison of values of different types and comparison with a value which is not an integer, float or atom always fails. Atoms are compared lexically.
{DetB +X ?B} {IsValueB +X ?B}
X is determined.
{'==B' X Y ?B}
Equality test. The expression {Value.'==' X Y} does not impose any constraints on X and Y (used for expansion of infix expressions and terms s == t).
fun {Value.'==B' X Y} if X = Y then True else False fi end
{'=' X Y}
Equality assertion. The expression {Value.'=' X Y} imposes the equality constraint X = Y.
proc {Value.'=' X Y} X = Y end
{'\\ =B' X Y ?B}
X is not equal to Y (used for expansion of infix expressions and terms s =¯ t).
fun {Value.'\\ =B' X Y} if X = Y then False else True fi end
{'=<B' +A1 +A2 ?B} {'=<B' +F1 +F2 ?B} {'=<B' +I1 +I2 ?B}
AFI1 is less than or equal to AFI2 (see `=<` in The Definition of Kernel Oz [11] ; used for expansion of infix expressions and terms s =< t).
{'<B' +A1 +A2 ?B} {'<B' +F1 +F2 ?B} {'<B' +I1 +I2 ?B}
AFI1 is less than AFI2 (used for expansion of infix expressions and terms s < t).
{'>=B' +A1 +A2 ?B} {'>=B' +F1 +F2 ?B} {'>=B' +I1 +I2 ?B}
AFI1 is greater than or equal to AFI2 (used for expansion of infix expressions and terms s >= t).
{'>B' +A1 +A2 ?B} {'>B' +F1 +F2 ?B} {'>B' +I1 +I2 ?B}
AFI1 is greater than AFI2 (used for expansion of infix expressions and terms s > t).
{Max +A1 +A2 ?A3} {Max +F1 +F2 ?F3} {Max +I1 +I2 ?I3}
AFI3 is the maximum of AFI1 and AFI2.
{Min +A1 +A2 ?A3} {Min +F1 +F2 ?F3} {Min +I1 +I2 ?I3}
AFI3 is the minimum of AFI1 and AFI2.
{type +X ?A}
Constrains A to an atom describing the type of X. Possible values for A are: atom, name, procedure, cell, float, int, tuple, and record. Note that {Value.type X tuple} fails if X is an atom or name, and only succeeds for proper tuples with at least one subtree, and similarly {Value.type X record} succeeds only for proper records.
The module NoNumber contains procedures operating on nonnumerical values, i.e. records and tuples.
{IsNoNumberB +X ?B}
X is a tuple or record.
{Label +RT ?L}
L is label of RT.
{Width +RT ?I}
I is width of RT.
{Subtree +R +L ?X} {Subtree +T +I ?X}
X is subtree of RT at feature LI. Fails, if RT has no subtree at LI.
{'.' +R +L ?X} {'.' +T +I ?X}
X is subtree of RT at feature LI. Fails and may give a type error, if RT has no subtree at LI. Used for expansion of infix term s . t.
{HasSubtreeAtB +R +L ?B} {HasSubtreeAtB +T +I ?B}
RT has subtree at feature LI.
The module Record contains procedures operating on records.
{IsRecordB +X ?B}
X is a record.
{Record +L +Ls ?R}
R is a new record with label L, features Ls, and fresh variables at every element of Ls. For example, {Record L A R} suspends until L is bound to a literal, say b, and A is bound to a list of literals, say [c d], and then binds R to b(c:_ d:_).
{Arity +R ?As}
As is arity of R, i.e. the list of atomic features in alphabetical order.
{Adjoin +R1 +R2 ?R3}
R3 is the result of adjoining R1 with R2. Note that R1 may not be a chunk.
{AdjoinAt +R1 +L X ?R2}
R2 is the result of adjoining the subtree X to R1 at feature L.
{AdjoinList +R1 +Ts ?R2}
R2 is the result of adjoining to R1 all entries of Ts. Ts is a finite list of pairs whose first components are literals, representing features. Features further right overwrite features further left. For example, the application {AdjoinList a(b:1 c:2) [d#3 c#4 d#5] X} constrains X to a(b:1 c:4 d:5).
{map +R1 +P ?R2} {foldL +R +P X ?Y} {foldR +R +P X ?Y} {forAllB +R +P ?B} {forSomeB +R +P ?B} {filterB +R1 +P ?R2} {partitionB +R1 +P ?R2 ?R3} {takeWhileB +R1 +P ?R2} {dropWhileB +R1 +P ?R2} {takeDropWhileB +R1 +P ?R2 ?R3} {mapInd +R1 +P ?R2} {foldLInd +R +P X ?Y} {foldRInd +R +P X ?Y} {forAllIndB +R +P ?B} {forSomeIndB +R +P ?B} {filterIndB +R1 +P ?R2} {partitionIndB +R1 +P ?R2 ?R3} {takeWhileIndB +R1 +P ?R2} {dropWhileIndB +R1 +P ?R2} {takeDropWhileIndB +R1 +P ?R2 ?R3}
For a description of the various procedures see the description for List. All procedures process the fields of the records in ascending order of their atomic features (as given by <). Records computed as output by one of the procedures ( Record.map, for instance) will have the same label as the input record. For instance, the application {Record.map a(b:1 c:2) fun {$ I I+1 end R}} will constrain R to a(b:2 c:3). The index variants (for instance Record.mapInd) use the features of the record as indices (where the procedural argument always takes the index as first and the field as second argument). For example, {Record.mapInd a(b:1 c:2) fun {$ A I A(I+1) end R}} constrains R to a(b:b(2) c:c(3)).
{zip +R1 +R2 +P ?R3}
Given two records R1 and R2 of the same arity, (see Arity) and a ternary procedure P, R3 is constrained to a record with the same arity and label as R1 such that all elements A of R1's arity satisfy { P R1. A R2. A R3. A}. For example,{Record.zip f(jim:1 jack:2 joe:3) g(jim:a jack:b joe:c) fun {$ X Y} X#Y end R}constrains R to the record f(jim:1#a jack:2#b joe:3#c).
{subtract +R1 +A ?R2}
R2 is R1 without feature +A if there is one.
{toList +R ?Xs}
Xs contains the fields at the atomic features of R as elements. For example {Record.toList f(a:1 b:2) Xs} constrains Xs to [1 2].
{toListInd +R ?Xs}
Xs is a property list that contains the feature-field pairs of the atomic features of R as elements. For example, {Record.toListInd f(a:1 b:2) Xs} constrains Xs to [a#1 b#2].
The module Tuple contains procedures operating on tuples.
{IsTupleB +X ?B}
X is a tuple.
{Tuple +L +I ?T}
T is a new tuple with label L and fresh variables at features 1 through I (natural number). For example, {Tuple L N T} suspends until L is bound to a literal, say b, and N is bound to a number, say 4, whereupon T is bound to b(_ _ _ _).
{ExtendTuple +T1 X ?T2}
T2 is the result of extending T1 by the subtree X at the end.
{arity +T ?Is}
Is is list of integers from 1 to the width of T.
{adjoin +T1 +T2 ?T3}
T3 is the result of adjoining T1 with T2, similar to Adjoin for records. For example, the application {Tuple.adjoin a(1 2 3) b(4 5) X} constrains X to b(4 5 3).
{adjoinAt +T1 +I X ?T2}
T2 is the result of adjoining to T1 at feature I the subtree X, similar to AdjoinAt for records. If necessary, fresh variables are inserted. For example, the application {Tuple.adjoinAt a(1 2 3) 6 4 X} constrains X to a(1 2 3 _ _ 4).
{adjoinList +T1 +Ts ?T2}
T2 is the result of adjoining to T1 all entries of Ts, similar to AdjoinList for records. Ts is a finite list of pairs whose first components are integers. If necessary, fresh variables are inserted. For example, the application {Tuple.adjoinList a(1 2) [4#3 6#4] X} constrains X to a(1 2 _ 3 _ 4).
{map +T1 +P ?T2} {foldL +T +P X ?Y} {foldR +T +P X ?Y} {forAllB +T +P ?B} {forSomeB +T +P ?B} {filterB +T1 +P ?T2} {partitionB +T1 +P ?T2 ?T3} {takeWhileB +T1 +P ?T2} {dropWhileB +T1 +P ?T2} {takeDropWhileB +T1 +P ?T2 ?T3} {mapInd +T1 +P ?T2} {foldLInd +T +P X ?Y} {foldRInd +T +P X ?Y} {forAllIndB +T +P ?B} {forSomeIndB +T +P ?B} {filterIndB +T1 +P ?T2} {partitionIndB +T1 +P ?T2 ?T3} {takeWhileIndB +T1 +P ?T2} {dropWhileIndB +T1 +P ?T2} {takeDropWhileIndB +T1 +P ?T2 ?T3}
For a description see the description for List. All procedures process the fields of the tuple in ascending order. Tuples computed as output by one of the procedures ( Tuple.map, for instance) will have the same label as the input tuple. Hence, the application {Tuple.map a(1 2) fun {$ I I+1 end T}} will constrain T to a(2 3). The index variants (e.g., Tuple.mapInd) use the features as index. For example, {Tuple.mapInd a(3 2 1) Pow T} constrains T to a(1 4 3).
{zip +T1 +T2 +P ?T3}
Given two tuples T1 and T2 of the same width n, and a ternary procedure P, T3 is constrained to a tuple of width n such that all k with 1 < k < n satisfy { P R1.k R2.k R3.k}. For example,{Tuple.zip f(1 2 3) g(a b c) fun {$ X Y} X#Y end T}will constrain T to the tuple f(1#a 2#b 3#c).
{toList +T ?Xs}
Xs contains the subtrees of T as elements.
{toListInd +T ?Xs}
Xs is a property list that contains the feature-field pairs of T as elements. For example {Tuple.toListInd f(a b) Xs} will constrain Xs to [1#a 2#b].
The module Literal contains procedures operating on literals, i.e. atoms and names.
{IsLiteralB +X ?B}
X is a literal.
The module Atom contains procedures operating on atoms.
{IsAtomB +X ?B}
X is an atom.
{concat +A1 +A2 ?A3}
A3 is the concatenation of A1 and A2. For example, {Atom.concat 'abc' 'def' X} binds X to 'abcdef'.
{length +A ?I}
I is length of A. For example, {Atom.length 'abc' X} binds X to 3.
{AtomToString +A ?S}
S is the string (list of integers) representing atom A according to ISO 8859-1. See also StringToAtom . For example, {AtomToString 'abc' S} binds S to [97 98 99].
The module Name contains procedures operating on names.
{IsNameB +X ?B}
X is a name.
{NewName ?N} Name.new=NewName
N is constrained to a new name.
The module Chunk contains procedures operating on chunks.
{IsChunkB +X ?B}
X is a chunk.
ChunkLabel
is bound to the label of chunks.
The module Procedure contains procedures operating on procedures.
{IsProcedureB +X ?B}
X is a procedure.
{ProcedureArity +P ?I}
I is the number of arguments that P takes.
{isNaryB +X +I ?B}
X is a procedure with arity I.
{printName +P ?A}
A is an atom, often the name of the variable, to which P was bound in the source code.
{Link +P ?ServerP}
ServerP is bound to a server procedure that serves demands of the form ServerP X by inserting the demand in a stream. For every element X of the stream, P X is executed.
The module Cell contains procedures operating on cells.
{IsCellB +X ?B}
X is a cell.
{NewCell X ?Cell}
Cell is constrained to a new cell with initial content X.
{Exchange +Cell X Y}
X is bound to the current content of Cell. Y is the new content of Cell.
The module Number contains procedures operating on numbers. Numbers in Oz are either integers or floats. The following arithmetic procedures are defined both on integers and on floats, however, there is no implicit conversion.
{IsNumberB +X ?B}
X is a number.
{'+' +F1 +F2 ?F3} {'+' +I1 +I2 ?I3}
FI3 is the sum of FI1 and FI2 (see `+` in The Definition of Kernel Oz [11] ; used for expansion of infix term s + t).
{'-' +F1 +F2 ?F3} {'-' +I1 +I2 ?I3}
FI3 is the difference of FI1 and FI2 (see `-` in The Definition of Kernel Oz [11] ; used for expansion of infix term s - t).
{'*' +F1 +F2 ?F3} {'*' +I1 +I2 ?I3}
FI3 is the product of FI1 and FI2 (see `*` in The Definition of Kernel Oz [11] ; used for expansion of infix term s * t).
{'~' +F1 ?F2} {'~' +I1 ?I2}
FI2 is the negation of FI1 (used for expansion of prefix term t).
{Pow +F1 +F2 ?F3} {Pow +I1 +I2 ?I3}
FI3 is FI1 raised to the power of FI2.
{Abs +F1 ?F2} {Abs +I1 ?I2}
FI2 is the absolute value of FI1.
The module Int contains procedures operating on integers.
{IsIntB +X ?B}
X is an integer.
{IsNatB +I ?B}
I is a natural number, i.e. integer greater or equal 0.
{IsOddB +I ?B}
I is an odd integer.
{IsEvenB +I ?B}
I is an even integer.
{'div' +I1 +I2 ?I3}
I3 is I1 integer-divided by I2, rounding towards 0 (used for expansion of infix term s div t).
local fun {Div I1 I2} case I1<I2 then 0 else 1 + {Div I1-I2 I2} end end in fun {Int.'div' I1={IsInt} I2={IsInt}} {Div {Abs I1} {Abs I2}} * case I1*I2>=0 then 1 else ~1 end end end
{'mod' +I1 +I2 ?I3}
I3 is I1 modulo I2 (used for expansion of infix term s mod t).
fun {Int.'mod' I1 I2} I1 - I2 * (I1 div I2) end
{IntToFloat +I ?F}
F is the float closest to integer I.
{toString +I ?S}
S is the string describing the integer I.
The module Float contains procedures operating on floating point numbers.
{IsFloatB +X ?B}
X is a float.
{'/' +F1 +F2 ?F3}
F3 is F1 divided by F2 (see / in The Definition of Kernel Oz [11] ; used for expansion of infix term s / t).
{Exp +F1 ?F2}
F2 is F1 raised to the power of e.
{Log +F1 ?F2}
F2 is the logarithm to the base e of F1.
{Sqrt +F1 ?F2}
F2 is the square root of F1.
{Ceil +F1 ?F2}
F2 is the ceiling of F1 (rounding towards positive infinity).
{Floor +F1 ?F2}
F2 is the floor of F1 (rounding towards negative infinity).
{round +F1 ?F2}
F2 is the closest integral value to F1. If there are two closest, F1 is rounded to the closest even integral value such that {Float.round 1.5 X} constrains X to 2.0 and {Float.round 2.5 X} constrains X to 2.0.
{Sin +F1 ?F2}
F2 is the sine of F1.
{Cos +F1 ?F2}
F2 is the cosine of F1.
{Tan +F1 ?F2}
F2 is the tangent of F1.
{Asin +F1 ?F2}
F2 is the arc sine of F1.
{Acos +F1 ?F2}
F2 is the arc cosine of F1.
{Atan +F1 ?F2}
F2 is the arc tangent of F1.
{atan2 +F1 +F2 ?F3}
F3 is the principal value of the arc tangent of F1/ F2, using the signs of both arguments to determine the quadrant of the return value. A domain error can occur if both arguments are zero.
{FloatToInt +F ?I}
I is the integer closest to float F. If there are two closest, F is rounded to the closest even integer such that {FloatToInt 1.5 X} constrains X to 2 and {FloatToInt 2.5 X} constrains X to 2.
{toString +F ?S}
S is the string describing the float F.
The module Char contains procedures operating on characters. Characters are integers between 0 and 255, used for building strings. For convenient handling of characters the module Char is available. For the coding of characters with integers, we use the standard ISO 8859-1. The functionality the module provides for is similar to the ctype.h module of ANSI C, see for instance [6].
{IsCharB +X ?B}
X is a character, i.e. an integer between 0 and 255.
{isLowerB +I ?B}
I encodes a lower-case letter.
{isUpperB +I ?B}
I encodes an upper-case letter.
{isDigitB +I ?B}
I encodes a digit.
{isSpaceB +I ?B}
I encodes a white space, i.e. either a space, a form feed ( ""), a newline ( ""), a carriage return ( ""), a tab ( ""), or a vertical tab ( "").
{isPunctB +I ?B}
I encodes a punctuation character, i.e. a visible character, which is not a space, a digit, or a letter.
{isCntrlB +I ?B}
I encodes a control character.
{isAlphaB +I ?B}
I is a letter.
{isAlNumB +I ?B}
I is a letter or a digit.
{isGraphB +I ?B}
I is a visible character, with space excluded.
{isPrintB +I ?B}
I is a visible character, with space included.
{isXDigitB +I ?B}
I is a hexadecimal digit.
{type +I ?A}
Maps I to its simple type A, i.e. one of to the atoms lower, upper, digit, space, punct, or other. Fails, if I is not a character.
{toLower +I1 ?I2}
If I1 is an upper-case letter, I2 is constrained to the corresponding lower-case letter. Otherwise I2 is I1. Fails, if I1 is not a character.
{toUpper +I1 ?I2}
If I1 is a lower-case letter, I2 is constrained to the corresponding upper-case letter. Otherwise I2 is I1. Fails, if I1 is not a character.
{toAtom +I ?A}
Maps I to the corresponding atom A. If I is zero, A will be the atom ''. Fails, if I is not a character.
The module Inheritable contains procedures operating on objects and classes. The system procedures that define the behavior of Oz objects and classes are also given in this section.
{IsInheritableB +X ?B}
X is an object or class.
{New +OC +RT ?O}
O is created by inheriting from (the class of) OC with initial message RT (see Program).
{'class' +OC ?C}
C is the class of OC if OC is an object and OC if OC is a class.
{methodNames +OC ?Ls}
Ls is the alphabetically sorted list of public (atomic) method names that the object +OC or the instances of the class +OC can serve.
Classes are created using expressions and terms of the
class ... end. This syntax is translated
to the application of the system
procedure `class`,
given in the Program .
The function Inherit
is local to the procedure `class`
and computes the records of all attributes,
features and methods, respectively, of an object or class
by adjoining the records of new attributes, features and methods
of all inherited objects or classes. The function Inherit uses
the procedure Class.precedence described on page
that defines the mechanism for multiple inheritance.
Objects are created using the procedure New given in
Program
. The procedure New calls the
inherited method `ooCreate`, providing the object protocol.
The class UrObject defines the standard object protocol of Oz,
given on page
.
Object and class creation can be combined using the syntax
create ... end, which is translated to the application of
the system procedure `create`,
given in the Program
.
local fun {Inherit C} {FoldL {Class.precedence C} fun {$ Attr#FreeAttr#Feat#FreeFeat#Methods Canc} CancAttr=Canc.`ooNewAttr` CancFeat=Canc.`ooNewFeat` in {Adjoin Attr CancAttr} #{Append FreeAttr {FilterB Canc.`ooNewFreeAttr` fun {$ X} {Not {HasSubtreeAtB CancAttr X}} end}} #{Adjoin Feat Canc.`ooNewFeat`} #{Append FreeFeat {FilterB Canc.`ooNewFreeFeat` fun {$ X} {Not {HasSubtreeAtB CancFeat X}} end}} #{Adjoin Methods Canc.`ooNewMethods`} end attributes#nil#features#nil#methods } end in proc {`class` FromList NewAttr NewFreeAttr NewFeat NewFreeFeat NewMethods ?C} AllAttr AllFreeAttr AllFeat AllFreeFeat AllMethods in C = ChunkLabel(`ooAllAttr` : AllAttr `ooNewAttr` : NewAttr `ooAllFreeAttr` : AllFreeAttr `ooNewFreeAttr` : NewFreeAttr `ooAllFeat` : AllFeat `ooNewFeat` : NewFeat `ooAllFreeFeat` : AllFreeFeat `ooNewFreeFeat` : NewFreeFeat `ooAllMethods` : AllMethods `ooNewMethods` : NewMethods `ooParents` : {Map FromList Inheritable.'class'} `ooClassId` : {NewName}) AllAttr#AllFreeAttr#AllFeat#AllFreeFeat#AllMethods = {Inherit C} end end
proc {New OC={IsInheritable} WithMessage={IsNoNumber} ?O} C={Inheritable.'class' OC} in {C.`ooAllMethods`.`ooCreate` _ `ooCreate`(WithMessage C) O _} end
proc {`create` FromList NewAttr NewFreeAttr NewFeat NewFreeFeat WithMessage NewMethods ?Self} Class={`class` FromList NewAttr NewFreeAttr NewFeat NewFreeFeat NewMethods} in {Inheritable.new Class WithMessage ?Self} end
Combined Class and Object Creation
The module Class contains procedures operating on classes.
{IsClassB +X ?B}
X is a class.
{parents +C ?Cs}
Cs is list of direct parents of C.
{precedence +C ?Cs}
Used in the function Inherit in order to compute the precedence list Cs of classes that a given class C inherits from directly or indirectly, including C itself. If the classes that C inherits from directly or indirectly cannot be ordered such that every class is greater than its parents and classes further right in a list of parents are greater than classes further left, the inheritance graph has a cycle and an error is reported. Otherwise, all total orderings that can be obtained from the resulting partial ordering are considered. If adjunction of the records containing the newly defined attributes, features, and methods, respectively, of every inherited class in increasing order yields different results for two of the total orderings, the inheritance is underspecified and an error is reported. Otherwise, Cs is bound to one of the total orderings, represented by a list of classes in increasing order, containing C itself as last element.
UrObject
class providing the protocol for creating objects (see page) and the following methods, all described in detail in Programming in Oz [3] .
RT|RTr
Implements batches together with method nil, see Program.
nil
Implements batches together with method |; also used to make expressions state using, see Program.
class BatchClass meth nil true end meth RT|RTr <<RT>> <<BatchClass RTr>> end end class UrObject from BatchClass ... end
sync(?O)
Synchronization method.
meth sync(?O) O = self end
sendSync(+O +RT)
The message RT is sent to O and the sender is synchronized upon the event that the message has delivered.
meth sendSync(O RT) case {DetB {O [RT sync($)]}} then <<nil>> end end
slave(O)
O is made a slave of the executing object (see method getSlaves).
unSlave(O)
O is declared to be no slave of the executing object (see method getSlaves).
getSlaves(Os)
Os is the list of all objects of which the executing object is declared to be the master (see methods slave and unSlave).
otherwise(RT)
The method otherwise is applied when the method lookup in object or method application fails. Its argument is the message that caused the failure. UrObject's method otherwise displays an error message.
close
self and all its slaves are closed.
Objects are created using the procedure New given in
Program . The procedure New calls the
inherited method `ooCreate`, providing the object protocol.
The class UrObject defines the standard object protocol of Oz,
given in Program
.
class UrObject %%% stuff deleted meth !`ooCreate`(WithMessage={IsNoNumber} C) Methods = C.`ooAllMethods` InitState Cell={NewCell InitState} proc {Send Message={IsNoNumber}} State NewState in {Exchange Cell State NewState} case {Label State} of closed then NewState=closed else {Serve State Message NewState} end end fun {Serve State Message} case {HasSubtreeAtB Methods {Label Message}} then {Methods.{Label Message} State Message self} else {Methods.otherwise State otherwise(Message) self} end end in self = {Adjoin {Adjoin {Adjoin C.`ooAllFeat` {Record features C.`ooAllFreeFeat`}} object(`ooClass`:C `ooClosed`:_)} Send} InitState = {Serve {Adjoin C.`ooAllAttr` {Record attributes C.`ooAllFreeAttr`}} WithMessage} end end
The class Class.list provides for a number of higher-order methods, i.e. methods that take an object or class as argument and iteratively apply a method of this object or class. We explain the method forAll in detail, the remaining methods are similar and work like the corresponding procedures in module List.
forAllB(+Xs +OC ?B +L<=Private)
If L is given, the method with method name L of OC is iteratively applied to all elements of Xs. If L is not given, the lexically first public method name of OC is iteratively applied to all elements of Xs.
meth forAllB(Xs OC ?B L<=Private) case L==Private then <<Class.list ForAllB(Xs OC {Inheritable.methodNames O}.1 ?B)>> else <<Class.list ForAllB(Xs OC L ?B)>> end end meth ForAllB(Xs OC L ?B) B=case Xs of nil then True [] X|Xr then <<OC L(X )>> andthen <<Class.list ForAllB(Xr OC L )>> end endThe variable Private is bound a local name. Example of usage:
create Counter from UrObject attr val:0 meth inc val <- @val + 1 end meth addAll(Xs) <<Class.list forAll(Xs class meth add(X) val <- @val + X end end)>> end endThe method addAll(Xs) adds all elements of Xs to the current value of the counter.
forSomeB(+Xs +OC ?B +L<=Private)
Similar to forAllB, see also List.forSomeB.
map(+Xs +OC ?Ys +L<=Private)
Similar to forAllB, see also List.forAll.
foldL(+Xs +OC X ?Y +L<=Private)
Similar to forAllB, see also List.foldL.
foldR(+Xs +OC X ?Y +L<=Private)
Similar to forAllB, see also List.foldR.
filterB(+Xs +OC ?Ys +L<=Private)
Similar to forAllB, see also List.filterB.
forAllIndB(+Xs +OC +L<=Private) forSomeIndB(+Xs +OC +L<=Private) mapInd(+Xs +OC ?Ys +L<=Private) foldLInd(+Xs +OC X ?Y +L<=Private) foldRInd(+Xs +OC X ?Y +L<=Private) filterIndB(+Xs +OC ?Ys +L<=Private)
Similar to the respective method without Ind, except that the first argument of the higher-order method is the position of the current element of the list, see also List.forAllIndB.
Port
Class inheriting from UrObject and providing for the functionality of ports as described in [5]. Its methods are given below:
open(Xs)
The port is initialized to the stream Xs.
send(X)
The data X is entered in the port.
close
The port is closed.
The module Object contains procedures operating on objects.
{IsObjectB +X ?B}
X is a object.
{closedB +O ?B}
Constrains B to True when O applies UrObject's method close.
{CallMethod +O RT}
applies the appropriate method of O to RT without using O's state. Works only if the method does not access or assign attributes.
The module Bool contains procedures operating on the truth values True and False represented by names.
True
positive truth value.
False
negative truth value.
{IsBoolB +X ?B}
X is True or False.
{Not +B1 ?B2}
B2 is negation of truth value B1.
The module List contains procedures operating on lists, including a number of higher-order list processing procedures.
{IsListB +X ?B}
X is finite list. Diverges, if X is infinite list.
{Append +Xs Ys ?Zs}
Zs is the result of appending Ys to Xs.
{MemberB X +Ys ?B}
X is member of Ys.
{Length +Xs ?I}
I is length of Xs.
{Nth +Xs +I ?Y}
Y is Ith element of Xs.
{subtract +Xs Y ?Zs}
Zs is Xs without the leftmost occurrence of Y if there is one.
{subB Xs Ys ?B}
Xs is sublist of Ys where Xs is a sublist of Ys if Ys contains all elements of Xs in the same order as Xs but not necessarily in succession. For example, [a b] is a sublist of both [1 a b 2] and [1 a 2 b 3], but not of [b a].
{Reverse +Xs ?Ys}
Ys is the result reverting Xs.
{SortB +Xs +P ?Ys}
Ys is the result of sorting Xs using the ordering P (a binary procedure for Sort and a binary boolean function for SortB). Sort and SortB are implemented using the mergesort algorithm.
{MergeB +Xs +Ys +P ?Zs}
Zs is the result of merging Xs and Ys using the ordering P (a binary procedure for Merge and a binary boolean function for MergeB).
{Flatten +Xs ?Ys}
Ys is the result of flattening Xs.
{List +I ?Xs}
Constrains Xs to a list of length I without imposing constraints on the elements.
{withTail +I X ?Xs}
Constrains Xs to a list with at least I elements whose rest is X without imposing constraints on the first I elements.
{number +I ?Xs}
Constrains Xs to a list with I elements, where the elements are 1, 2, ..., I.
{take +Xs +I ?Ys}
Constrains Ys to the list of the first I elements of Xs, or to Xs if it is shorter.
{drop +Xs +I ?Ys}
Constrains Ys to the list where the first I elements of Xs are removed, or to nil if it is shorter.
{takeDrop +Xs +I ?Ys ?Zs}
Constrains Ys to {List.take Xs I}, and Zs to {List.drop Xs I}.
{last +Xs ?Y}
Constrains Y to the last element of Xs.Most of the higher-order functionality for lists we will present is well known from higher order functional languages such as SML [1] or Haskell [4].
{Map +Xs +P ?Ys}
Applies the binary procedure P to all elements of Xs and Ys. It is used like {Map [12 13 1] IntToFloat Fs}, constraining Fs to [12.0 13.0 1.0].
{FoldL +Xs +P X ?Y} {FoldR +Xs +P X ?Y}
Used for folding the elements of Xs by applying a ternary procedure P. Application of the left folding procedure{FoldL [X_1 ... X_n] P Z Out}reduces to{P ... {P {P Z X_1} X_2} ... X_n Out}For example,{FoldL [b c d] fun {$ X Y} f(X Y) end a Out}constrains Out to f(f(f(a b) c) d). Besides of the left folding procedure there exists a right folding variant. The application{FoldR [X_1 ... X_n] P Z Out}reduces to{P X_1 {P X_2 ... {P X_n Z} ...} Out}For example,{FoldR [a b c] fun {$ X Y} f(X Y) end d Out}constrains Out to f(a f(b f(c d))).
{FoldLTail +Xs +P X ?Y} {FoldRTail +Xs +P X ?Y}
Used for folding all tails of Xs by applying a ternary procedure P. Application of the left folding procedure{FoldLTail [X_1 ... X_n] P Z Out}reduces to{P ... {P {P Z [X_1 ... X_n]} [X_2 ... X_n]} ... [X_n] Out}The right folding procedure is analogous.
{ForAll +Xs +P}
Applies the unary procedure P to each element of Xs. The application{ForAll [X_1 ... X_n] P}reduces to the expression{P X_1} ... {P X_n}For example {ForAll [O1 O2 O3] proc {$ O {O do} end}} sends the message do to the objects O1, O2, and O3.
{ForAllB +Xs +P ?B}
B is True, if the binary boolean function P applied to each element of Xs results in True, and is False otherwise.
{ForAllTail Xs +P}
Applies the unary procedure P to each non- nil tail of Xs. The application{ForAllTail [X_1 ... X_n] P}reduces to the expression{P [X_1 ... X_n]} {P [X_2 ... X_n]} ... {P [X_n]}
{ForAllTailB +Xs +P ?B}
B is True, if the binary boolean function P applied to each non- nil tail Xs results in True, and is False otherwise.
{ForSome +Xs +P}
Succeeds, if for some element of Xs the application of the unary procedure P succeeds. Hence, one can think that the application{ForSome [X_1 ... X_n] P}reduces to the expressionif {P X_1} then true elseif ... elseif {P X_n} then true else false fi
{ForSomeB +Xs +P ?B}
B is True, if for some element of Xs the application of the unary boolean function P results in True, and is False otherwise.
{FilterB +Xs +P ?Ys} {partitionB +Xs +P ?Ys ?Zs}
FilterB constrains Ys to elements of Xs, which yield True as output upon application of P, where the ordering is preserved. For instance, the application {FilterB [1 4 2 3 6 5] IsOddB Ys} constrains Ys to [1 3 5]. The 4-ary procedure List.partitionB constrains a third list Zs to the elements which are in Xs but not in Ys, where the ordering is preserved as well. Hence,{List.partitionB [1 4 2 3 6 5] IsOddB Ys Zs}will constrain Ys to [1 3 5] and Zs to [4 2 6]. The procedures Filter and List.partition take as second argument a unary procedure instead of a unary boolean function. For instance, the application {Filter [1 4 2 3 6 5] IsOdd Ys} constrains Ys to [1 3 5].
{takeWhileB +Xs +P ?Ys} {dropWhileB +Xs +P ?Ys} {takeDropWhileB +Xs +P ?Ys ?Zs}
While FilterB selects all elements of a list which satisfy a certain condition, the procedure List.takeWhileB selects only the starting sequence of elements which fulfill this condition. Hence, the application {List.takeWhileB [1 4 2 3 6 5] IsOddB Ys} constrains Ys to [1]. The procedure List.dropWhileB is dual: It computes the remaining part of the list. For example, {List.dropWhileB [1 4 2 3 6 5] IsOddB Ys} constrains Ys to [4 2 3 6 5]. For convenience, List.takeDropWhileB combines the functionality from both, List.takeWhileB and List.dropWhileB. For example, the application {List.takeDropWhileB [1 4 2 3 6 5] IsOddB Ys Zs} will constrain Ys to [1] and Zs to [4 2 3 6 5]. The procedures List.takeWhile, List.dropWhile, List.takeDropWhile take a unary procedure as second argument instead of a unary boolean function.
{mapInd +Xs +P ?Ys} {foldLInd +Xs +P X ?Y} {foldRInd +Xs +P X ?Y} {foldLTailInd +Xs +P X ?Y} {foldRTailInd +Xs +P X ?Y} {forAllIndB +Xs +P ?B} {forAllTailIndB +Xs +P ?B} {forSomeIndB +Xs +P ?B} {filterIndB +Xs +P ?Ys} {partitionIndB +Xs +P ?Ys ?Zs} {takeWhileIndB +Xs +P ?Ys} {dropWhileIndB +Xs +P ?Ys} {takeDropWhileIndB +Xs +P ?Ys ?Zs}
Each procedure P given as a parameter to one of these procedures is applied with one additional integer parameter (in first argument position), giving the number of the element currently processed. For example,{List.mapInd [a b c d] fun {$ I A} I#A end IAs}will constrain IAs to [1#a 2#b 3#c 4#d].
{zip +Xs +Ys +P ?Zs}
Given two lists Xs and Ys of the same length n, and a ternary procedure P, Zs is constrained to a list of length n such that, for all k with 1 < k < n, the kth element X of Xs, Y of Ys and Z of Zs satisfy { P X Y Z}. For example,{List.zip [1 6 3] [4 5 6] Max Xs}constrains Xs to the list [4 6 6].
{toTuple +L +Xs ?T}
T is a tuple with label L that contains the elements of Xs as subtrees in the given order. For example,{List.toTuple '#' [a b c] T}constrains T to the tuple a # b # c.
{toRecord +L +Xs ?R}
R is a record with label L that contains for every element L1 # X1 of Xs a subtree X1 at feature L1. For example,{List.toRecord f [a#1 b#2 c#3] R}constrains R to the record f(a:1 b:2 c:3).
The module String contains
procedures operating on strings.
Strings are lists whose elements are characters (see
Section ). Thus all procedures operating on lists
are applicable to strings. This section describes
procedures applicable only to strings.
{IsStringB +X ?B}
X is string.
{isAtomB +S ?B}
Checks whether the string S might be converted to an atom.
{StringToAtom +S ?A}
Converts a string S to an atom A. See also AtomToString .
{isIntB +S ?B}
Checks whether the string S might be converted to an integer.
{toInt +S ?I}
Converts a string S to an integer I. See also Int.toString . If S violates the syntax of integers (see The Oz Notation [2] ), String.toInt fails.
{isFloatB +S ?B}
Checks whether the string S might be converted to a float.
{toFloat +S ?F}
Converts a string S to a float F. See also Float.toString . If S violates the syntax of floats (see The Oz Notation [2] ), Float.toString fails.
The module VirtualString contains procedures operating on virtual strings. Virtual strings are designed as a convenient way to combine strings, atoms, integers and floats to compound strings without explicit concatenation and conversion.
{IsVirtualStringB +X ?B}
X is a virtual string. Virtual strings are defined recursively as the set of all integers, floats, atoms, strings, and tuples with label '#' whose subtrees are virtual strings.
{toString +V ?S}
Converts a virtual string V to a string S. The transformation is straightforward: Atoms, integers and floats are transformed into strings using AtomToString, Int.toString and Float.toString, respectively, where in numbers - is used instead of ; a tuple with label '#' is concatenation, and both nil and '#' denote the empty string. The following relation holds for all virtual strings V_1 and V_2:{VirtualString.toString V_1#V_2} = {Append {VirtualString.toString V_1} {VirtualString.toString V_2}}Thus VirtualString.toString maps # homomorphically to Append.
{length +V ?I}
Defined as{Length {VirtualString.toString V} I}
{changeSign +V1 V2 ?V3}
V3 is a virtual string derived from V1 where all occurrences of the unary minus sign for integers and floats are replaced by the virtual string V2.