mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Release calc version 2.10.2t30
This commit is contained in:
77
help/list
Normal file
77
help/list
Normal file
@@ -0,0 +1,77 @@
|
||||
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
|
||||
|
||||
LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
append, delete, insert, islist, pop, push, remove, rsearch, search, size
|
Reference in New Issue
Block a user