# Class `std.list`

Tables as lists.

## Prototype Chain

    table
     `-> Object
          `-> List

## Objects

std.list.List | An Object derived List.

## Functions

std.list.append (l, x) | Append an item to a list.
std.list.compare (l, m) | Compare two lists element-by-element, from left-to-right.
std.list.concat (l, ...) | Concatenate the elements from any number of lists.
std.list.cons (l, x) | Prepend an item to a list.
std.list.rep (l, n) | Repeat a list.
std.list.sub (l[, from=1[, to=#l]]) | Return a sub-range of a list.
std.list.tail (l) | Return a list with its first element removed.

## Metamethods

std.list:__add (l, e) | Append element to list.
std.list:__concat (l, m) | Concatenate lists.
std.list:__le (l, m) | List equality or order operator.
std.list:__lt (l, m) | List order operator.

## Objects

std.list.List
  An Object derived List.

## Functions

Methods

std.list.append (l, x)
  Append an item to a list.

  ### Parameters:

  - l List a list
  - x item

  ### Returns:

  List new list with x appended

  ### Usage:

      longer = append (short, "last")

std.list.compare (l, m)
  Compare two lists element-by-element, from left-to-right.

  ### Parameters:

  - l List a list
  - m List or table another list, or table

  ### Returns:

  -1 if l is less than m, 0 if they are the same, and 1 if l is greater than m

  ### Usage:

      if a_list:compare (another_list) == 0 then print "same" end

std.list.concat (l, ...)
  Concatenate the elements from any number of lists.

  ### Parameters:

  - l List a list
  - ... tuple of lists

  ### Returns:

  List new list with elements from arguments

  ### Usage:

       --> {1, 2, 3, {4, 5}, 6, 7}
       list.concat ({1, 2, 3}, {{4, 5}, 6, 7})

std.list.cons (l, x)
  Prepend an item to a list.

  ### Parameters:

  - l List a list
  - x item

  ### Returns:

  List new list with x followed by elements of l

  ### Usage:

       --> {"x", 1, 2, 3}
       list.cons ({1, 2, 3}, "x")

std.list.rep (l, n)
  Repeat a list.

  ### Parameters:

  - l List a list
  - n int number of times to repeat

  ### Returns:

  List n copies of l appended together

  ### Usage:

       --> {1, 2, 3, 1, 2, 3, 1, 2, 3}
       list.rep ({1, 2, 3}, 3)

std.list.sub (l[, from=1[, to=#l]])
  Return a sub-range of a list. (The equivalent of ??? on strings; negative list indices count from the end of the list.)

  ### Parameters:

  - l List a list
  - from int start of range (default 1)
  - to int end of range (default #l)

  ### Returns:

  List new list containing elements between from and to inclusive

  ### Usage:

       --> {3, 4, 5}
       list.sub ({1, 2, 3, 4, 5, 6}, 3, 5)

std.list.tail (l)
  Return a list with its first element removed.

  ### Parameters:

  - l List a list

  ### Returns:

  List new list with all but the first element of l

  ### Usage:

       --> {3, {4, 5}, 6, 7}
       list.tail {{1, 2}, 3, {4, 5}, 6, 7}

## Metamethods

std.list:__add (l, e)
  Append element to list.

  ### Parameters:

  - l List a list
  - e element to append

  ### See also:

  append

  ### Usage:

      list = list + "element"

std.list:__concat (l, m)
  Concatenate lists.

  ### Parameters:

  - l List a list
  - m List or table another list, or table (hash part is ignored)

  ### See also:

  concat

  ### Usage:

      new = alist .. {"append", "these", "elements"}

std.list:__le (l, m)
  List equality or order operator.

  ### Parameters:

  - l List a list
  - m List another list

  ### See also:

  compare

  ### Usage:

      min = list1 <= list2 and list1 or list2

std.list:__lt (l, m)
  List order operator.

  ### Parameters:

  - l List a list
  - m List another list

  ### See also:

  compare

  ### Usage:

      max = list1 > list2 and list1 or list2

generated by LDoc 1.4.3 Last updated 2018-09-03 17:48:42