25 out <<
" " << l->item;
29 out <<
", " << l->item;
39 if (i == 0)
return rep->item;
40 return rep->next[i - 1];
81 while (!
is_nil (l->next)) {
91 if (
is_nil (l->next))
return l->item;
111 return l1.rep ==
l2.rep;
119 if (
l1->item !=
l2->item)
return false;
121 return l1->next ==
l2->next;
128 return (
l1->item !=
l2->item) || (
l1->next !=
l2->next);
135 return (
l1->item ==
l2->item) && (
l1->next <
l2->next);
142 return (
l1->item ==
l2->item) && (
l1->next <=
l2->next);
155 while (!
is_nil (l->next)) {
223 if (
is_nil (l))
return false;
224 if (l->item ==
what)
return true;
#define ASSERT(cond, msg)
Macro used to assert that a condition is true, and throw an exception with an error message if the co...
The list class represents a linked list.
T & operator[](int i)
Overloaded subscript operator to access the item at a specific index in the list.
bool operator!=(list< T > l1, list< T > l2)
list< T > remove(list< T > l, T what)
Create a new list with a specific item removed.
bool strong_equal(list< T > l1, list< T > l2)
Check if two lists are strongly equal (i.e., have the same items in the same order).
bool operator<(list< T > l1, list< T > l2)
bool operator==(list< T > l1, list< T > l2)
list< T > copy(list< T > l)
Create a copy of a list.
list< T > operator*(list< T > l1, T x)
Create a new list by appending an item to the end of an existing list.
list< T > reverse(list< T > l)
Create a new list with the items in reverse order.
list< T > & operator>>(T item, list< T > &l)
T last_item(list< T > l)
Return the last item of the list. The input list must not be an empty list.
bool operator<=(list< T > l1, list< T > l2)
list< T > head(list< T > l, int n)
Get the first n items of a list.
list< T > tail(list< T > l, int n)
Get all but the first n items of a list.
int N(list< T > l)
Get the number of items in a list.
T & access_last(list< T > &l)
Get a reference to the last item in a list.
tm_ostream & operator<<(tm_ostream &out, list< T > l)
list< T > & suppress_last(list< T > &l)
Remove the last item from a list.
bool contains(list< T > l, T what)
Check if a list contains a specific item.