Sequence Representation
Sequence: TYPE = AC.Object;
SequenceData: TYPE = REF SequenceDataRec;
SequenceDataRec:
TYPE =
RECORD [
SEQUENCE lengthPlus1:[1..65534] OF AC.Object
];
An empty sequence is represented with non-NIL data field consisting of a SequenceDataRec of length 0.
Selection
Select:
AC.BinaryOp;
firstArg is a Sequence, secondArg is an Ints.Int specifying position to select. Returns NIL if can't do.
First:
AC.UnaryOp;
firstArg = Sequence, return first element. Return NIL if empty.
Last:
AC.UnaryOp;
firstArg = Sequence, return last element. Return NIL if empty.
Length: AC.ElementRankOp;
Operations
Equal:
AC.BinaryPredicate;
Prepend:
AC.BinaryOp;
firstArg = Sequence, secondArg = new Item. Place secondArg at the beginning of firstArg. secondArg must belong to firstArg's elementStructure.
Append:
AC.BinaryOp;
firstArg = Sequence, secondArg = new Item. Place secondArg at the end of firstArg. secondArg must belong to firstArg's elementStructure.
Insert:
AC.TernaryOp;
firstArg is a Sequence, secondArg is an Ints.Int specifying position after which to insert new item, thirdArg is new item. secondArg = 0 means insert at beginning, secondArg = i means insert after ith element of sequence. thirdArg must belong to firstArg's elementStructure.
Error if secondArg > Length[firstArg].
Delete:
AC.BinaryOp;
firstArg is a Sequence, secondArg is a positive Ints.Int specifying position to delete.
Error if secondArg<1 OR secondArg > Length[firstArg].
DeleteLast:
AC.UnaryOp;
firstArg is a Sequence. If length = 0, noOp.
Find:
AC.BinaryOp;
firstArg is a Sequence, secondArg is an element of the Sequence's elementStructure. Returns an Ints.Int giving position of secondArg in firstArg if found, else returns NIL
Concatenate:
AC.BinaryOp;
Concatenate two Sequences. Must have same elementStructure.
MapUnaryElementOp:
AC.BinaryMixedOp;
firstArg is a Sequence, secondArg is a unary Method (e.g. UnaryOp, UnaryPredicate) on its elementStructure, result is Sequence of results of applications of the unary operation to the elements of firstArg.
MapBinaryElementOp:
AC.TernaryMixedOp;
firstArg and secondArg are Sequences over the same elementStructure, and of the same length. thirdArg is a binary Method (e.g. BinaryOp, BinaryPredicate) on elementStructure. The result is a Sequence of the results of the application of the binary operation to corresponding pairs of elements of firstArg and secondArg.