File 'base/lists.tcl' (part of 'Pool_Base')


Home | Packages | Files | Procedures | Classes | Keywords | External packages


Written by
Andreas Kupries
Description
Collection of useful list operations
Depends on
Tcl
Keywords
list operations

::pool::list::apply (cmd list)

Applies cmd to all entries of list and concatenates the individual results into a single list. The cmd must accept exactly one argument.
Argument: cmdThe command executed for each entry.
Argument: listThe list to look at.
Returns: A list containing all results of the application of cmd to the list.

::pool::list::assign (varList list)

byBrent Welch
Assign a set of variables from a list of values. If there are more values than variables, they are ignored. If there are fewer values than variables, the variables get the empty string.
Argument: varListList of variables to assign the values to.
Argument: listThe list to assign to the variables.

::pool::list::delete (listVar value)

byBrent Welch
Delete an item from the list stored in listVar, by value.
Argument: listVarThe name of the variable containing the list to manipulate.
Argument: valueThe value searched (and deleted from the list).
Returns: 1 if the item was present, else 0.

::pool::list::exchange (listVar position newItem)

Removes the item at position from the list stored in variable listVar and inserts newItem in its place.
Argument: listVarName of variable containing the list to be manipulated.
Argument: positionIndex of the element to remove.
Argument: newItemThe element to insert into the place of the removed one.
Returns: The changed list.

::pool::list::filter (list pattern)

All words contained in the list pattern are removed from list. In set-notation: result = list - pattern
Argument: listThe list to filter
Argument: patternThe list of words to remove from list
Returns: Setdifference of list and pattern

::pool::list::head (list)

Argument: listThe list to look at.
Returns: The first element of list.

::pool::list::last (list)

Argument: listThe list to look at.
Returns: The last element of list.

::pool::list::lengthOfLongestEntry (list)

Determines the length of the longest entry contained in the list.
Argument: listThe list to look at.
Returns: The length of the longest entry.

::pool::list::match (list pattern)

All words not contained in list pattern are removed from list. In set-notation: result = intersect (list, pattern). This is not completely true, duplicate entries in 'list' remain in the result, given that they appear at all.
Argument: listThe list to filter
Argument: patternThe list of words to accept in list
Returns: Nearly the intersection of list and pattern

::pool::list::pop (listVar)

Removes the last element of the list contained in variable listVar.
Argument: listVarname of variable containing the list to manipulate.
Returns: The last element of the list, or {} in case of an empty list.

::pool::list::prepend (listVar newElement)

The list stored in the variable listVar is shifted up by one. newElement is inserted afterward into the now open head position.
Notes: The same as ::pool::list::unshift, just under a different name.
Argument: listVarThe name of the variable containing the list to manipulate.
Argument: newElementData to insert before the head of the list.
Returns: newElement

::pool::list::prev (list)

Argument: listThe list to look at.
Returns: Everything before the last element of list.

::pool::list::projection (list column)

Treats list as list of lists and extracts the column'th element of each list item. If list is seen as matrix, then the procedure returns the data of the specified column.
Argument: listThe list to search through.
Argument: columnIndex of the column to extract from list.
Returns: A list containing the extracted items.

::pool::list::push (listvar args)

The same as 'lappend', provided for symmetry only.
Argument: listvarThe name of the variable containing the list to manipulate.
Argument: argsList of objects to append to the list.
Returns: As of 'lappend'.

::pool::list::remove (listVar position)

Removes the item at position from the list stored in variable listVar.
Argument: listVarThe name of variable containing the list to manipulate.
Argument: positionindex of the element to remove.
Returns: The changed list.

::pool::list::reverse (list)

Argument: listthe list to manipulate.
Returns: Returns the reversed list.

::pool::list::select (list indices)

General permutation / selection of list elements. Takes the elements of list whose indices were given to the command and returns a new list containing them, in the specified order.
Argument: listThe list to select from, the list to permute.
Argument: indicesA list containing the indices of the elements to select.
Returns: is a list containing the selected elementes, in the order specified by indices.

::pool::list::shift (listVar)

The list stored in the variable listVar is shifted down by one.
Argument: listVarname of the variable containing the list to manipulate.
Returns: The first element of the list stored in listVar, or {} for an empty list. The latter is not a sure signal, as the list may contain empty elements.

::pool::list::tail (list)

Argument: listThe list to look at.
Returns: Everything behind the first element of list.

::pool::list::uniq (list)

Removes duplicate entries from list.
Argument: listThe list to manipulate.
Returns: The modified list.

::pool::list::unshift (listVar newElement)

The list stored in the variable listVar is shifted up by one. newElement is inserted afterward into the now open head position.
Notes: The same as ::pool::list::prepend, just under a different name.
Argument: listVarThe name of the variable containing the list to manipulate.
Argument: newElementData to insert before the head of the list.
Returns: newElement


Generated by AutoDoc 2.1 at 02/20/1999, invoked by Andreas Kupries