scala
object List

[source: `scala/List.scala`]

`` `object` List
  `extends` AnyRef

  This object provides methods for creating specialized lists, and for transforming special kinds of lists (e.g. lists of lists).

Author
  Martin Odersky and others
Version
  1.0, 15/07/2003

Method Summary
`def` | apply [A](xs : A*) : List[A] Create a list with given elements.
`def` | concat [A](xss : List[A]*) : List[A] Concatenate all the argument lists into a single list.
`def` | exists2 [A, B](xs : List[A], ys : List[B])(f : (A, B) => Boolean) : Boolean Tests whether the given predicate `p` holds for some corresponding elements of the argument lists.
`def` | flatten [A](xss : List[List[A]]) : List[A] Concatenate all the elements of a given list of lists.
`def` | forall2 [A, B](xs : List[A], ys : List[B])(f : (A, B) => Boolean) : Boolean Tests whether the given predicate `p` holds for all corresponding elements of the argument lists.
`def` | fromArray [A](arr : Array[A], start : Int, len : Int) : List[A] Converts a range of an array into a list.
`def` | fromArray [A](arr : Array[A]) : List[A] Converts an array into a list.
`def` | fromIterator [A](it : Iterator[A]) : List[A] Converts an iterator to a list.
`def` | fromString (str : String, separator : Char) : List[String] Parses a string which contains substrings separated by a separator character and returns a list of all substrings.
`def` | fromString (str : String) : List[Char] Returns the given string as a list of characters.
`def` | make [A](n : Int, elem : A) : List[A] Create a list containing several copies of an element.
`def` | map2 [A, B, C](xs : List[A], ys : List[B])(f : (A, B) => C) : List[C] Returns the list resulting from applying the given function `f` to corresponding elements of the argument lists.
`def` | map3 [A, B, C, D](xs : List[A], ys : List[B], zs : List[C])(f : (A, B, C) => D) : List[D] Returns the list resulting from applying the given function `f` to corresponding elements of the argument lists.
`def` | mapConserve [A <: AnyRef](xs : List[A])(f : (A) => A) : List[A] Like xs map f, but returns `xs` unchanged if function `f` maps all elements to themselves.
`def` | range (from : Int, end : Int) : List[Int] Create a sorted list of all integers in a range.
`def` | range (from : Int, end : Int, step : Int) : List[Int] Create a sorted list of all integers in a range.
`def` | range (from : Int, end : Int, step : (Int) => Int) : List[Int] Create a sorted list of all integers in a range.
`def` | tabulate [A](n : Int, maker : (Int) => A) : List[A] Create a list by applying a function to successive integers.
`def` | toString (xs : List[Char]) : String Returns the given list of characters as a string.
`def` | transpose [A](xss : List[List[A]]) : List[List[A]] Transposes a list of lists. pre: All element lists have the same length.
`def` | unapplySeq [A](x : List[A]) : Some[List[A]] for unapply matching
`def` | unzip [A, B](xs : List[(A, B)]) : (List[A], List[B]) Transforms a list of pair into a pair of lists.

Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized

Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf

Method Details

`` `def` apply[A](xs : A*) : List[A]

  Create a list with given elements.

Parameters
  `xs -` the elements to put in the list
Returns
  the list containing elements xs.

`` `def` unapplySeq[A](x : List[A]) : Some[List[A]]

  for unapply matching

`` `def` range(from : Int, end : Int) : List[Int]

  Create a sorted list of all integers in a range.

Parameters
  `from -` the start value of the list
  `end -` the end value of the list
Returns
  the sorted list of all integers in range [from;end).

`` `def` range(from : Int, end : Int, step : Int) : List[Int]

  Create a sorted list of all integers in a range.

Parameters
  `from -` the start value of the list
  `end -` the end value of the list
  `step -` the increment value of the list
Returns
  the sorted list of all integers in range [from;end).

`` `def` range(from : Int, end : Int, step : (Int) => Int) : List[Int]

  Create a sorted list of all integers in a range.

Parameters
  `from -` the start value of the list
  `end -` the end value of the list
  `step -` the increment function of the list
Returns
  the sorted list of all integers in range [from;end).

`` `def` make[A](n : Int, elem : A) : List[A]

  Create a list containing several copies of an element.

Parameters
  `n -` the length of the resulting list
  `elem -` the element composing the resulting list
Returns
  a list composed of n elements all equal to elem

`` `def` tabulate[A](n : Int, maker : (Int) => A) : List[A]

  Create a list by applying a function to successive integers.

Parameters
  `n -` the length of the resulting list
  `maker -` the procedure which, given an integer `n`, returns the nth element of the resulting list, where `n` is in interval `[0;n)`.
Returns
  the list obtained by applying the maker function to successive integers from 0 to n (exclusive).

`` `def` flatten[A](xss : List[List[A]]) : List[A]

  Concatenate all the elements of a given list of lists.

Parameters
  `xss -` the list of lists that are to be concatenated
Returns
  the concatenation of all the lists

`` `def` concat[A](xss : List[A]*) : List[A]

  Concatenate all the argument lists into a single list.

Parameters
  `xss -` the lists that are to be concatenated
Returns
  the concatenation of all the lists

`` `def` unzip[A, B](xs : List[(A, B)]) : (List[A], List[B])

  Transforms a list of pair into a pair of lists.

Parameters
  `xs -` the list of pairs to unzip
Returns
  a pair of lists: the first list in the pair contains the list

`` `def` fromIterator[A](it : Iterator[A]) : List[A]

  Converts an iterator to a list.

Parameters
  `it -` the iterator to convert
Returns
  a list that contains the elements returned by successive calls to `it.next`

`` `def` fromArray[A](arr : Array[A]) : List[A]

  Converts an array into a list.

Parameters
  `arr -` the array to convert
Returns
  a list that contains the same elements than `arr` in the same order

`` `def` fromArray[A](arr : Array[A], start : Int, len : Int) : List[A]

  Converts a range of an array into a list.

Parameters
  `arr -` the array to convert
  `start -` the first index to consider
  `len -` the lenght of the range to convert
Returns
  a list that contains the same elements than `arr` in the same order

`` `def` fromString(str : String, separator : Char) : List[String]

  Parses a string which contains substrings separated by a separator character and returns a list of all substrings.

Parameters
  `str -` the string to parse
  `separator -` the separator character
Returns
  the list of substrings

@deprecated
`` `def` fromString(str : String) : List[Char]

  Returns the given string as a list of characters.

Parameters
  `str -` the string to convert.
Returns
  the string as a list of characters.
Deprecated
  use `str.toList` instead

`` `def` toString(xs : List[Char]) : String

  Returns the given list of characters as a string.

Parameters
  `xs -` the list to convert.
Returns
  the list in form of a string.

`` `def` mapConserve[A <: AnyRef](xs : List[A])(f : (A) => A) : List[A]

  Like xs map f, but returns `xs` unchanged if function `f` maps all elements to themselves.

Parameters
  `xs -` ...
  `f -` ...
Returns
  ...

`` `def` map2[A, B, C](xs : List[A], ys : List[B])(f : (A, B) => C) : List[C]

  Returns the list resulting from applying the given function `f` to corresponding elements of the argument lists.

Parameters
  `f -` function to apply to each pair of elements.
Returns
  `[f(a0,b0), ..., f(an,bn)]` if the lists are `[a0, ..., ak]`, `[b0, ..., bl]` and `n = min(k,l)`

`` `def` map3[A, B, C, D](xs : List[A], ys : List[B], zs : List[C])(f : (A, B, C) => D) : List[D]

  Returns the list resulting from applying the given function `f` to corresponding elements of the argument lists.

Parameters
  `f -` function to apply to each pair of elements.
Returns
  `[f(a0,b0,c0), ..., f(an,bn,cn)]` if the lists are `[a0, ..., ak]`, `[b0, ..., bl]`, `[c0, ..., cm]` and `n = min(k,l,m)`

`` `def` forall2[A, B](xs : List[A], ys : List[B])(f : (A, B) => Boolean) : Boolean

  Tests whether the given predicate `p` holds for all corresponding elements of the argument lists.

Parameters
  `p -` function to apply to each pair of elements.
Returns
  `(p(a0,b0) && ... && p(an,bn))]` if the lists are `[a0, ..., ak]`; `[b0, ..., bl]` and `n = min(k,l)`

`` `def` exists2[A, B](xs : List[A], ys : List[B])(f : (A, B) => Boolean) : Boolean

  Tests whether the given predicate `p` holds for some corresponding elements of the argument lists.

Parameters
  `p -` function to apply to each pair of elements.
Returns
  `n != 0 && (p(a0,b0) || ... || p(an,bn))]` if the lists are `[a0, ..., ak]`, `[b0, ..., bl]` and `n = min(k,l)`

`` `def` transpose[A](xss : List[List[A]]) : List[List[A]]

  Transposes a list of lists. pre: All element lists have the same length.

Parameters
  `xss -` the list of lists
Returns
  the transposed list of lists