RopeList.mesa
This interface provides some utilities for manipulating lists of ropes.
Last Edited by: Stewart.pa, December 15, 1983 6:46 pm
DIRECTORY
Basics USING [Comparison],
Rope USING [ROPE];
RopeList:
CEDAR
DEFINITIONS =
BEGIN
Useful types.
Here are a collection of useful types.
CompareProc: TYPE = PROC [r1, r2: Rope.ROPE] RETURNS [Basics.Comparison];
Predicates.
EqualLists:
PROC [l1, l2:
LIST
OF Rope.
ROPE, case:
BOOL ←
TRUE]
RETURNS [
BOOL];
Are the lists element by element Rope.Equal[case]?
Memb:
PROC [list:
LIST
OF Rope.
ROPE, r: Rope.
ROPE, case:
BOOL ←
TRUE]
RETURNS [
BOOL];
Is the given rope on the list?
Constructors.
These procedures do not disturb their arguments.
Cons:
PROC [list:
LIST
OF Rope.
ROPE, r: Rope.
ROPE]
RETURNS [
LIST
OF Rope.
ROPE] =
INLINE {
RETURN[CONS[r, list]];
};
Append:
PROC [l1, l2:
LIST
OF Rope.
ROPE]
RETURNS [
LIST
OF Rope.
ROPE];
Copies l1 then attaches l2 to the end of it. If l2 is NIL, copies top level of l1.
CopyTopList:
PROC [list:
LIST
OF Rope.
ROPE]
RETURNS [
LIST
OF Rope.
ROPE] =
INLINE {
RETURN[Append[list, NIL]];
};
Returns a copy of the list.
Remove:
PROC [list:
LIST
OF Rope.
ROPE, r: Rope.
ROPE, case:
BOOL ←
TRUE]
RETURNS [
LIST
OF Rope.
ROPE];
Remove the given rope from the list, if it is there. Removes all matching elements
Reverse:
PROC [list:
LIST
OF Rope.
ROPE]
RETURNS [
LIST
OF Rope.
ROPE];
Reverse the list.
Destructive Constructors.
Like the constructors above, but these avoid CONSing by destroying the list passed in as an argument.
DAppend:
PROC [l1, l2:
LIST
OF Rope.
ROPE]
RETURNS [
LIST
OF Rope.
ROPE];
Appends l2 to the end of l1.
DRemove:
PROC [list:
LIST
OF Rope.
ROPE, r: Rope.
ROPE, case:
BOOL ←
TRUE]
RETURNS [
LIST
OF Rope.
ROPE];
Remove the given rope from the list, if it is there. Removes only the first matching element.
DReverse:
PROC [list:
LIST
OF Rope.
ROPE]
RETURNS [
LIST
OF Rope.
ROPE];
Reverse the list.
Miscellaneous.
Length:
PROC [list:
LIST
OF Rope.
ROPE]
RETURNS [
INT];
Count the number of elements.
Map:
PROC [list:
LIST
OF Rope.
ROPE, proc:
PROC [Rope.
ROPE]];
Call proc with each element of the list.
Sorting.
Sort:
PROC [list:
LIST
OF Rope.
ROPE, compareProc: CompareProc]
RETURNS [
LIST
OF Rope.
ROPE];
Sorts the list according to CompareProc. Sort is destructive.
Compare: CompareProc;
Compares according to CHAR order.
IgnoreCase: CompareProc;
Compares according to CHAR order except that case distinctions are ignored.
END.
December 15, 1983 6:20 pm, Stewart, copied from List.mesa