Dictionary of Meaning
<<Back
Please select a letter:
A |
B |
C |
D |
E |
F |
G |
H |
I |
J |
K |
L |
M |
N |
O |
P |
Q |
R |
S |
T |
U |
V |
W |
X |
Y |
Z |
0-9
Click here for Shopping
List
*** Shopping-Tip: List
{{wiktionary|list}}
{{selfref|About lists in :
:Lists}}
:''This article is about the word list as used in computer science. For other uses, see
list (disambiguation).''
In
computer science, a '''list''' is usually defined as an instance of an
abstract data type (ADT) formalizing the concept of an ordered collection of entities. For example, an ADT for untyped,
mutable object mutable lists may be specified in terms of a
constructor and four operations:
* a constructor for creating an empty list;
* an operation for testing whether or not a list is empty;
* an operation for prepending an entity to a list (''
cons'' in Lisp);
* an operation for determining the first component (or the "head") of a list (''
car (function) car in Lisp'');
* an operation for referring to the list consisting of all the components of a list except for its first (or its "tail") (''
cdr'' in Lisp);
Image:Singly_linked_list.png An example of a list - a single linked-list, with 3 integer values|thumb|right
In practice, lists are usually implemented using
arrays or
linked lists of some sort; due to lists sharing certain properties with arrays and linked lists. Informally, the term list is sometimes used synonymously with
linked list. A '''sequence''' is another name, emphasizing the ordering and suggesting that it may not be a linked list.
Characteristics
Lists have the following properties:
*The '''size''' of '''lists'''. It indicates how many elements are there in the
lists.
* The '''contents''' or '''data type''' of lists. They may or may not vary at
runtime, depending on implementations.
* '''sorted''' or '''unsorted '''
*'''Random access''' over lists may or may not be possible, depending on
implementations.
*'''Equality''' of lists:
**In mathematics, sometimes
equality (mathematics) equality of lists is defined simply in terms of
Identity (object-oriented programming) object identity: two lists are equal if and only if they are the same object.
**In modern
programming languages, equality of lists is normally defined in terms of
structural equality of the corresponding entries, except that if the lists are typed, then the list types may also be relevant.
*Lists may be '''typed'''. This implies that the entries in a list must have
datatype types that are compatible with the list's type. It is common that lists are typed when they are implemented using arrays.
Applications
As the name implies, lists can be used to store a list of records. The items in a list can be sorted or unsorted for the purpose of fast search (
binary search for instance)or fast inserting.
Implementations
In
Lisp programming language Lisp, lists are the fundamental data type and can represent both program code and data. In most dialects, the list of the first three prime numbers could be written as
(list 2 3 5). In several dialects of Lisp, including
Scheme programming language Scheme, a list is collection of pairs, consisting of a value and a pointer to the next pair (or null value).
The standard way of implementing lists, originating with Lisp, is to have each element of the list contain both its value and a pointer indicating the location of the next element in the list. This results in either a
linked list or a
tree data structure tree, depending on whether the list has nested sublists. Although LISP implementations (such as the LISP used for the Symbolics 3600) often use "compressed lists" which are arrays.
Some languages do not offer a list data structure, but offer the use of associative arrays or some kind of table to emulate lists. For example,
Lua programming language Lua provides tables. Although Lua stores lists that have numerical indices as arrays internally, they still appear as hash tables.
Some languages may instead implement lists using other data structures, such as
arrays. However, it is generally assumed that elements can be inserted into a list in
constant time, while access of a random element in a list requires
linear time; this is to be contrasted with an array (or ''vector''), for which the time complexities are reversed.
Lists can be manipulated using
iteration or
recursion. The former is often preferred in non-
tail-recursive languages, and languages in which recursion over lists is for some other reason uncomfortable. The latter is generally preferred in
functional languages, since iteration is associated with arrays and often regarded as
Imperative programming imperative.
Because in computing, lists are easier to realize than sets, a finite
set in mathematical sense can be realized as a list with additional restrictions, that is, duplicate elements are disallowed and such that order is irrelevant. If the list is sorted, it speeds up determining if a given item is already in the set but in order to ensure the order, it requires more time to add new entry to the list.
See also
*
data structures
*
Linked list
*
Multiset
*
Tuple
Category:Data structures
be:СьпіÑ?
da:Liste (datastruktur)
de:Liste
fr:Liste
nl:Lijst
no:Liste
pl:Lista
sl:seznam
pt:Lista
see
:Lists
{{H:h|editor toc}}
List basics
{|border=1
!wikitext!!rendering
|-
|
* Lists are easy to do:
** start every line with a star
*** more stars means deeper levels
|
* Lists are easy to do:
** start every line with a star
*** more stars means deeper levels
|-
|
*A newline
*in a list
marks the end of the list.
Of course
*you can
*start again.
|
*A newline
*in a list
marks the end of the list.
Of course
*you can
*start again.
|-
|
# Numbered lists are also good
## very organized
## easy to follow
|
# Numbered lists are also good
## very organized
## easy to follow
|-
|
* You can also
**break lines<br>inside lists<br>like this
|
* You can also
**break lines
inside lists
like this
|-
|
; Definition list : list of definitions
; item : the item's definition
|
; Definition list : list of definitions
; item : the item's definition
|-
|
* You can even create mixed lists
*# and nest them
*#* like this
*#*; can I mix definition list as well?
*#*: yes
*#*; how?
*#*: it's easy as
*#*:* a
*#*:* b
*#*:* c
|
* You can even create mixed lists
*# and nest them
*#* like this
*#*; can I mix definition list as well?
*#*: yes
*#*; how?
*#*: it's easy as
*#*:* a
*#*:* b
*#*:* c
|}
A blank line within a list item or between list items
(In this and the next section numbered lists are used in examples; unnumbered lists give a corresponding result, except that a possible problem of a list restarting with 1 is not applicable.)
A list item can only be one paragraph unless HTML tags are used within it. Otherwise, the new paragraph will end the list. If the list is unnumbered, a new list can be started, but if the list is numbered, the numbering will start over from 1.
In the case of a numbered list, the same is used to have a blank line between list items (more or less necessary if there is a multi-paragraph list item, otherwise the lay-out is confusing); in the case of an unnumbered list one can simply start a new one.
Using
One way to produce a paragraph break in a list is to use
. The spacing between paragraphs may look odd, however.
Example:
#
Abc dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
Def dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
#
Ghi dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
Jkl dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
Result:
#Abc dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
Def dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
#Ghi dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
Jkl dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
Using and
To get more convincing spacing, you can instead put
and
tags around each paragraph in the list item.
Example:
#
Abc dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.Def dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
#
Ghi dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.Jkl dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
Result:
#Abc dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
Def dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
#Ghi dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
Jkl dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text dummy text.
Numbered list across sections
Since this disturbs section numbering it is on a separate page
Help:List/Numbered list across sections.
Continuing a list item after a sub-item
In HTML, a list item may contain several sublists, not necessarily adjacent; thus there may be parts of the list item not only before the first sublist, but also between sublists, and after the last one; however, in wiki-syntax, sublists follow the same rules as sections of a page: the only possible part of the list item not in sublists is before the first sublist.
In the case of an unnumbered first-level list in wikitext code this limitation can be overcome by splitting the list into multiple lists; indented text between the partial lists may visually serve as part of a list item after a sublist; however, this may give, depending on CSS, a blank line before and after each list, in which case, for uniformity, every first-level list item could be made a separate list.
Numbered lists illustrate that what should look like one list may, for the software, consist of multiple lists; unnumbered lists give a corresponding result, except that the problem of restarting with 1 is not applicable.
{| style="border:1px;border-spacing:1px;background-color:black;" cellpadding="5px"
|- style="background-color:white;"
|
- list item A1
- list item B1
- list item B2
continuing list item A1
- list item A2
|
- list item A1
- list item B1
- list item B2
continuing list item A1
- list item A2
|- style="background-color:#E0E0E0;font-weight:bold;text-align:center;"
| colspan="2" | vs.
|- style="background-color:white;"
|
#list item A1
##list item B1
##list item B2
#:continuing list item A1
#list item A2
|
#list item A1
##list item B1
##list item B2
#:continuing list item A1
#list item A2
|}
One level deeper, with a sublist item continuing after a sub-sublist, one gets even more blank lines; however, the continuation of the first-level list is not affected:
#list item A1
##list item B1
###list item C1
##:continuing list item B1
##list item B2
#list item A2
gives
#list item A1
##list item B1
###list item C1
##:continuing list item B1
##list item B2
#list item A2
See also {{tim|List demo}} and
Help:Section#Subdivisions in general subdivisions.
Extra indentation of lists
In a numbered list in a large font, some browsers do not show more than two digits, unless extra indentation is applied (if there are multiple columns: for each column).
:#abc
:#def
:#ghi
gives
:#abc
:#def
:#ghi
In the case that HTML has to be used (see next section), extra indentation of a list is achieved with the tags
:
gives
Some background explanation: a HTML list can have content before the first list item, distinguished from content before the list by its indentation; MediaWiki changes such content into a list item without a number displayed, but with implicit number 1; in particular a "list" can have content but no list items, which MediaWiki changes into a list with one unnumbered list item, which makes no difference: the only effect is indentation of the content; in the case mentioned the content is itself a numbered sublist.
Multi-column numbered lists
Specifying a starting value is useful for a numbered list with multiple columns, to avoid restarting from one in each column. This is only possible with HTML-syntax (for the first column either wiki-syntax or HTML-syntax can be used).
In combination with the extra indentation explained in the previous section:
{| valign="top"
|-
|
|
|}
gives
{| valign="top"
|-
|
|
|}
See also
wikicities:Template:List of Wikicities (
wikicities:Template talk:List of Wikicities talk,
wikicities:Special:Whatlinkshere/Template:List of Wikicities backlinks, [http://www.wikicities.com/index.php?title=Template:List_of_Wikicities&action=edit edit]).
{{h:f|enname=List}}
:''To find related topics in a list, see
{{{1}}}.''
Usage
To link to a list on a given topic (in an article or section), use {{list|list page name}}.
See also
* Template:Mainlist for linking to "main" lists in lists of lists
Category:List templates {{PAGENAME}}
*** Shopping-Tip: List