Carapace

List Class

List Creation

The most common way to create a list is with the list function e.g.

    (list 1 2 3 4) --> (1 2 3 4)

List Properties

None

List Methods

method name description
length return the no. of items in the list
head return the first item in the list
tail return a list of all items excluding the first in the supplied list
cons construct a list by creating a new one with the supplied head and tail
endCons surgically update this list by adding the supplied element on the end
reverse create a new list which is the reverse of this one
get get the nth item from the list (the first has index = 0)
set get the nth item from the list (the first has index = 0) -- this surgically updates the list
member search this list for the supplied item, returning its zero-based index if found
find treating the list as a list of attribute/value pairs, find the value for the given attribute
findAux treating the list as a list of attribute/value(s) entries, find the values for the given attribute
replaceHead surgically replace the head of this list with the supplied object
replaceTail surgically replace the tail of this list with the supplied list
string create a string representation of this list


length

Return the no. of items in the list.

Arguments: none

Return type: Integer


head

Return the first item in the list. An error is thrown if attempt to take the head of an empty list.

Arguments: none

Return type: Object


tailOf

Return a list of all items excluding the first in the supplied list.

Arguments: none

Return type: List


cons

Construct a list by creating a new one with the supplied head and tail.

Arguments:

newHeadObject

Return type: List


endCons

Surgically update this list by adding the supplied element on the end.

Arguments:

itemObject

Return type: the empty List ()


reverse

Return a list which is the reverse of this list.

Arguments: none

Return type: List


get

Get the nth item from the list (the first has index = 0).

Arguments:

idxInteger

Return type: Object


set

Set the nth item from the list (the first has index = 0). This surgically updates the list

Arguments:

idxInteger
newValueObject

Return type: the empty List () is returned.


member

Search this list for the supplied item, returning its zero-based index if found.

Arguments:

itemObject

Return type: Integer or the empty List ()


find

Treating the list as a list of attribute/value pairs, find the value for the given attribute.

Arguments:

attribObject

Return type: Object


findAux

Treating the list as a list of attribute/value(s) entries, find the values for the given attribute.

Arguments:

attribObject

Return type: Object


replaceHead

Surgically replace the head of this list with the supplied object.

Arguments:

newHeadObject

Return type: the empty List


replaceTail

Surgically replace the tail of this list with the supplied list.

Arguments:

newTailList

Return type: the empty List


string

Create a string representation of this list.

Arguments: none

Return type: String


Contents Index Current topic: objects Related links: builtin objects