DIRECTORY Rope, IO, AlgebraClasses; Sequences: CEDAR DEFINITIONS ~ BEGIN OPEN Rope, AC: AlgebraClasses; Sequence: TYPE = AC.Object; SequenceData: TYPE = REF SequenceDataRec; SequenceDataRec: TYPE = RECORD [ SEQUENCE lengthPlus1:[1..65534] OF AC.Object ]; SequenceStructureData: TYPE = REF SequenceStructureDataRec; SequenceStructureDataRec: TYPE = RECORD [ row: BOOL _ TRUE, elementStructure: AC.Object ]; MakeSequenceStructure: AC.SequenceStructureConstructor; PrintName: AC.ToRopeOp; ShortPrintName: AC.ToRopeOp; ElementStructure: AC.UnaryOp; Recast: AC.BinaryOp; CanRecast: AC.BinaryPredicate; ToExpr: AC.ToExprOp; LegalFirstChar: AC.LegalFirstCharOp; Read: AC.ReadOp; FromRope: AC.FromRopeOp; ToRope: AC.ToRopeOp; Write: AC.WriteOp; MakeSequence: AC.ListImbedOp; Select: AC.BinaryOp; First: AC.UnaryOp; Last: AC.UnaryOp; Length: AC.ElementRankOp; IsSubset: AC.BinaryPredicate; IsSubsequence: AC.BinaryPredicate; Equal: AC.BinaryPredicate; Prepend: AC.BinaryOp; Append: AC.BinaryOp; Insert: AC.TernaryOp; Delete: AC.BinaryOp; DeleteLast: AC.UnaryOp; Find: AC.BinaryOp; Concatenate: AC.BinaryOp; MapUnaryElementOp: AC.BinaryMixedOp; MapBinaryElementOp: AC.TernaryMixedOp; END. <Sequences.mesa Last Edited by: Arnon, May 3, 1986 3:53:47 pm PDT Variable-length sequences of elements of some elementStructure. Sequence Representation An empty sequence is represented with non-NIL data field consisting of a SequenceDataRec of length 0. Instance Data for Sequence Structures Sequence Structure Ops Conversion and IO Element Constructor Attempts to recast supplied elements into elementStructure. If data = NIL then returns a Sequence whose SequenceDataRec is of length 0. Element Selectors firstArg is a Sequence, secondArg is an Ints.Int specifying position to select. Returns NIL if can't do. firstArg = Sequence, return first element. Return NIL if empty. firstArg = Sequence, return last element. Return NIL if empty. Predicates firstArg and secondArg are Sequences. Returns TRUE if firstArg is a subset of secondArg. Returns FALSE if args have different elementStructures. firstArg and secondArg are Sequences. Returns TRUE if firstArg is a subsequence of secondArg. Returns FALSE if args have different elementStructures. Operations firstArg = Sequence, secondArg = new Item. Place secondArg at the beginning of firstArg. secondArg must belong to firstArg's elementStructure. firstArg = Sequence, secondArg = new Item. Place secondArg at the end of firstArg. secondArg must belong to firstArg's elementStructure. 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]. firstArg is a Sequence, secondArg is a positive Ints.Int specifying position to delete. Error if secondArg<1 OR secondArg > Length[firstArg]. firstArg is a Sequence. If length = 0, noOp. 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 two Sequences. Must have same elementStructure. 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. 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. Κά˜Jšœ™J™1J˜J˜Jšœ?™?J™šΟk ˜ Icodešœ˜Kšœ˜Kšœ˜—Ihead2šΟn œœ ˜Jšœœœœ˜'headšž™Jšœ œœ˜J˜Jšœœœ˜)J˜šœœœ˜ Jšœœœ˜,Jšœ˜—J˜Jšœe™e—šœ%™%Kšœœœ˜;šœœœ˜)Jšœœœ˜Kšœœ˜K˜——šœ™šžœœ˜7K˜—šž œœ ˜K˜—šžœœ ˜K˜—Kšžœœ ˜—šœ™šžœœ ˜J˜—šž œœ˜J˜—šžœœ ˜J˜—šžœœ˜$J˜—šžœœ˜J˜—šžœœ ˜J˜—šžœœ ˜J˜—Jšžœ ˜—šœ™šž œœ ˜Jšœ;™;JšœK™K——šœ™šžœœ ˜Kšœi™iK˜—šžœœ ˜Kšœ@™@K˜—šžœœ ˜Kšœ?™?K™—Kšžœœ˜—šž ™ šžœœ˜Kšœ’™’K™—šž œœ˜"Kšœ/œ5œ*™———šž ™ šžœœ˜J˜—šžœœ ˜Kšœ™K˜—šžœœ ˜Kšœ‰™‰K˜—šžœœ ˜Kšœ’™’Kšœ&™&K™—šžœœ ˜KšœW™WKšœ5™5K˜—šž œœ ˜Kšœ-™-K˜—šžœœ ˜Kšœ¬™¬K˜—šž œœ ˜Kšœ<™