Next Previous Contents

## 7. Functions that Create and Manipulate Lists

## 7.1 list_append

Synopsis

  Append an object to a list

Usage

  `list_append (List_Type object, Int_Type nth)`

Description

  The `list_append` function is like `list_insert` except this function inserts the object into the list after the `nth` item. See the documentation on `list_insert` for more details.

See Also

  `list_insert, list_delete, list_pop, list_new, list_reverse`

## 7.2 list_delete

Synopsis

  Remove an item from a list

Usage

  `list_delete (List_Type list, Int_Type nth)`

Description

  This function removes the `nth` item in the specified list. The first item in the list corresponds to a value of `nth` equal to zero. If `nth` is negative, then the indexing is with respect to the end of the list with the last item corresponding to `nth` equal to -1.

See Also

  `list_insert, list_append, list_pop, list_new, list_reverse`

## 7.3 list_insert

Synopsis

  Insert an item into a list

Usage

  `list_insert (List_Type list, object, Int_Type nth)`

Description

  This function may be used to insert an object before the `nth` position in a list. The first item in the list corresponds to a value of `nth` equal to zero. If `nth` is negative, then the indexing is with respect to the end of the list with the last item given by a value of `nth` equal to -1.

Notes

  It is important to note that

  > `

  >         list_insert (list, object, 0);

  > `

  is not the same as

  > `

  >         list = {object, list}

  > `

  since the latter creates a new list with two items, `object` and the old list.
See Also

  `list_append, list_pop, list_delete, list_new, list_reverse`

## 7.4 list_new

Synopsis

  Create a new list

Usage

  `List_Type list_new ()`

Description

  This function creates a new empty `List_Type` object. Such a list may also be created using the syntax

  > `

  >          list = {};

  > `

See Also

  `list_delete, list_insert, list_append, list_reverse, list_pop`

## 7.5 list_pop

Synopsis

  Extract an item from a list

Usage

  `object = list_pop (List_Type list [, Int_Type nth])`

Description

  The `list_pop` function returns a object from a list deleting the item from the list in the process. If the second argument is present, then it may be used to specify the position in the list where the item is to be obtained. If called with a single argument, the first item in the list will be used.

See Also

  `list_delete, list_insert, list_append, list_reverse, list_new`

## 7.6 list_reverse

Synopsis

  Reverse a list

Usage

  `list_reverse (List_Type list)`

Description

  This function may be used to reverse the items in list.

Notes

  This function does not create a new list. The list passed to the function will be reversed upon return from the function. If it is desired to create a separate reversed list, then a separate copy should be made, e.g.,

  > `

  >          rev_list = @list;
  >          list_reverse (rev_list);

  > `

See Also

  `list_new, list_insert, list_append, list_delete, list_pop`

Next Previous Contents