mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
104 lines
3.6 KiB
Plaintext
104 lines
3.6 KiB
Plaintext
NAME
|
|
list - create list of specified values
|
|
|
|
SYNOPSIS
|
|
list([x, [x, ... ]])
|
|
|
|
TYPES
|
|
x any, &any
|
|
|
|
return list
|
|
|
|
DESCRIPTION
|
|
This function returns a list that is composed of the arguments x.
|
|
If no args are given, an empty list is returned.
|
|
|
|
Lists are a sequence of values which are doubly linked so that
|
|
elements can be removed or inserted anywhere within the list.
|
|
The function 'list' creates a list with possible initial elements.
|
|
For example,
|
|
|
|
x = list(4, 6, 7);
|
|
|
|
creates a list in the variable x of three elements, in the order
|
|
4, 6, and 7.
|
|
|
|
The 'push' and 'pop' functions insert or remove an element from
|
|
the beginning of the list. The 'append' and 'remove' functions
|
|
insert or remove an element from the end of the list. The 'insert'
|
|
and 'delete' functions insert or delete an element from the middle
|
|
(or ends) of a list. The functions which insert elements return
|
|
the null value, but the functions which remove an element return
|
|
the element as their value. The 'size' function returns the number
|
|
of elements in the list.
|
|
|
|
Note that these functions manipulate the actual list argument,
|
|
instead of returning a new list. Thus in the example:
|
|
|
|
push(x, 9);
|
|
|
|
x becomes a list of four elements, in the order 9, 4, 6, and 7.
|
|
Lists can be copied by assigning them to another variable.
|
|
|
|
An arbitrary element of a linked list can be accessed by using the
|
|
double-bracket operator. The beginning of the list has index 0.
|
|
Thus in the new list x above, the expression x[[0]] returns the
|
|
value of the first element of the list, which is 9. Note that this
|
|
indexing does not remove elements from the list.
|
|
|
|
Since lists are doubly linked in memory, random access to arbitrary
|
|
elements can be slow if the list is large. However, for each list
|
|
a pointer is kept to the latest indexed element, thus relatively
|
|
sequential accesses to the elements in a list will not be slow.
|
|
|
|
Lists can be searched for particular values by using the 'search'
|
|
and 'rsearch' functions. They return the element number of the
|
|
found value (zero based), or null if the value does not exist in
|
|
the list.
|
|
|
|
EXAMPLE
|
|
; list(2,"three",4i)
|
|
|
|
list (3 elements, 3 nonzero):
|
|
[[0]] = 2
|
|
[[1]] = "three"
|
|
[[2]] = 4i
|
|
|
|
; list()
|
|
list (0 elements, 0 nonzero)
|
|
|
|
LIMITS
|
|
none
|
|
|
|
LINK LIBRARY
|
|
none
|
|
|
|
SEE ALSO
|
|
append, delete, insert, islist, pop, push, remove, rsearch, search, size
|
|
|
|
## Copyright (C) 1999 Landon Curt Noll
|
|
##
|
|
## Calc is open software; you can redistribute it and/or modify it under
|
|
## the terms of the version 2.1 of the GNU Lesser General Public License
|
|
## as published by the Free Software Foundation.
|
|
##
|
|
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
|
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
|
## Public License for more details.
|
|
##
|
|
## A copy of version 2.1 of the GNU Lesser General Public License is
|
|
## distributed with calc under the filename COPYING-LGPL. You should have
|
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
##
|
|
## @(#) $Revision: 30.1 $
|
|
## @(#) $Id: list,v 30.1 2007/03/16 11:10:42 chongo Exp $
|
|
## @(#) $Source: /usr/local/src/bin/calc/help/RCS/list,v $
|
|
##
|
|
## Under source code control: 1994/03/19 03:13:19
|
|
## File existed as early as: 1994
|
|
##
|
|
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
|
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|