List Functions
CSL supports the following functions for the manipulation of lists. The use of these functions is illustrated in an example, below.
asPair(object-1, object-2)
Creates a Pair containing the two objects. These objects can later be accessed using pair.first and pair.second respectively.
asList(element-1, … , element-n)
Returns a new list containing the arguments as elements.  If there are no arguments (as in asList()), an empty list is returned. (Note that an empty list is different from a list whose only member is null, which is returned by asList(null).) The expression listCons(a,asList()) returns the list containing a.
listCons(newHead, list)
Returns a new list that prepends newHead to list. (This is implemented without copying list; it is performed in constant time, that is, the amount of time it takes is the same regardless of the size of the list.)
listAsString(list, [separator])
Converts each element of the list (or any collection) into a string and concatenates them, separating them with the given separator. If unspecified, the default separator is ', ' (comma-space), giving a similar result to asString(), but without the surrounding square brackets.
For example:
listAsString(asList('one', 'two', 'three')) - returns 'one, two, three'
listAsString(asList('one', 'two', 'three'), ' | ') - returns 'one | two | three'
listAsString(asList(1, 2, 3)) - returns '1.0, 2.0, 3.0'
If list is null, an empty string is returned (the same as for an empty collection). Otherwise, if list is not a collection the result matches asString().
listFirst(list)
Returns the first element of list. (This is performed in constant time.)
listGet(list, i)
Returns ith element the list. List indexing is1-based (that is, a list’s first element has index 1 rather than index 0). If i is not a number between 1 and the size of the list, an exception is issued.
listRest(list)
Returns a list that includes everything in list except its first element. (This is performed in constant time; the list is not copied or modified.)
listReverse(list)
Returns a new list that contains the elements of list in reverse order. (The time to perform this increases linearly with the number of elements in the list.)
listSize(list)
Returns the number of elements in list. Returns 0 if list is not a list. This function works if the underlying object is any type of Java Collection.
Example
 
ListOfUpstreamSiblings(op) = ListOfUpstreamSiblings1(op,op.parent.children)
 
// if we run out of siblings, or we hit op, return the empty list
ListOfUpstreamSiblings1(op,siblings) = { _
asList() _
if (siblings == null or listFirst(siblings) == op) 
listCons(listFirst(siblings),ListOfUpstreamSiblings1(op,listRest(siblings)))_
otherwise }
Note that recursion such as is used in this example does not scale with list size, and can lead to stack overflow errors with large lists.