include "lists.m" lists := load Lists Lists->PATH; append: fn[T](l: list of T, x: T): list of T; combine: fn[T](l1: list of T, l2: list of T): list of T; concat: fn[T](l1: list of T, l2: list of T): list of T; delete: fn[T](x: T, l: list of T): list of T for { T => eq: fn(a, b: T): int; }; ismember: fn[T](x: T, l: list of T): int for { T => eq: fn(a, b: T): int; }; last: fn[T](l: list of T): T; pair: fn[T1, T2](l1: list of T1, l2: list of T2): list of (T1, T2); reverse: fn[T](l: list of T): list of T; unpair: fn[T1, T2](l: list of (T1, T2)): (list of T1, list of T2); allsat: fn[T](p: ref fn(x: T): int, l: list of T): int; anysat: fn[T](p: ref fn(x: T): int, l: list of T): int; filter: fn[T](p: ref fn(x: T): int, l: list of T): list of T; map: fn[T](f: ref fn(x: T): T, l: list of T): list of T; partition: fn[T](p: ref fn(x: T): int, l: list of T): (list of T, list of T);
First, there is a group of common list operations.
Append returns a new list with the elements of l followed by the element x.
Combine returns a new list that has the elements of both l1 and l2 in no defined order.
Concat returns a new list that has the elements of l1 followed by the elements of l2.
Delete returns a new list in which the first element of l that is equal to x has been removed (all others remain). X must be an adt reference type T with an operation T.eq that returns true (non-zero) if two values of type T are considered equal.
Ismember returns 1 if there is an element of l that is equal to x.
Last returns the value of the element at the end of list l. A run-time error occurs if l is nil.
Pair takes two lists l1 and l2, and returns a new list of tuples (v1, v2) in which each element of l1 has been paired with the corresponding element of l2. A run-time error occurs if the lists are not equal in length.
Reverse returns a new list containing the elements of l in reverse order.
Unpair takes a list of tuples (v1, v2) and returns a tuple of lists (l1, l2) where l1 contains the first element of each tuple, and l2 contains the second element of each tuple.
A second group of operations applies a function f or a Boolean predicate p to each element of a list l, returning a transformed list or a Boolean value. A predicate p must return non-zero if its parameter value satisfies its condition, and must return zero if it does not.
Allsat returns 1 if all elements of l satisfy p, and returns 0 otherwise.
Anysat returns 1 if any element of l satisfies p, and returns 0 otherwise.
Filter returns a new list containing only the elements of l that satisfy p.
Map returns a new list in which each element of l has been transformed by f (ie, if l is e0::e1::... then the result is f(e0)::f(e1)::...).
Partition returns a tuple of lists (l1, l2) of lists where l1 contains all elements of l that satisfy p and l2 contains all elements of l that do not satisfy p.
LISTS(2 ) | Rev: Tue Mar 27 12:41:01 GMT 2007 |