list

Getting started with list

Remarks#

For HTML lists see html-list.

The current list tag-info also mentions a lot about lists of expressions joined by logical (short-circuiting) operators.

Lists are a construct provided by, or created in, many programming languages and environments (especially if they provide generics) grouping same-typed objects, with an order and so often available by index, but normally without a maximum length. They are one of fundamental collections.

Possible subtopics:

  • Types of lists

Further information: Wikipedia

Availability

Various forms of lists are either a basic data type or can be fairly easily constructed in most programming environments.

For example, linked lists can be constructed if the programming language provides structures and pointers or references, or even with just two (resizable) arrays, one of next indexes and the other of the type being stored.

Simple List and Nested List

List can contain n number of items. The items in list are separated by comma

 >> a = [1,2,3]

To access an element in the list use the index. The index starts from 0

 >> a[0]
 >> 1

Lists can be nested.

>> nested_list = [ [1,2,3], ['a','b','c'] ]
>> nested_list[0]
>> [1,2,3]
>> nested_list[1][0]
>> 'a'

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow