Monkey/Language/Lists

What are Lists?
In Monkey, lists are a set of objects that are encapsulated in an object, and read in a set sequential order. Lists have the power to be read forwards, backwards, traversed object-by-object, sorted, and offer a node-level access for insertion and queries.

Example:

A list is created like any other object with the 'NEW' keyword. It differs from other objects because it requires a type specifier. Type specifiers (or type parameters) are defined using the greater than-less than signs:. In the above example, the list 'mylist' is a list of 'Obj's, which is a class of three fields: x, y, and z.

'EachIn' will automatically iterate through a list, assigning the object to the iterating variable. EachIn will exit the loop when a NULL is reached, signaling the end of the list.

What are Nodes?
Syntax for a list's node:

Nodes are also created when an object is added to a list:

Nodes can return a value from the list:

Nodes can be used to iterate through a list backwards:

Nodes can insert a value into a list, using the Node constructor (the New command):

Nodes can remove a value from a list, although be sure to be done with that node before you remove it: