in scala
object List

object List
extends Object
with ScalaObject

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
final def apply[A](xs: A*): List[A]
     Create a list with given elements.
final def flatten[a](l: List[List[a]]): List[a]
     Concatenate all the elements of a given list of lists.
final def fromArray[a](arr: Array[a], start: Int, len: Int): List[a]
     Converts a range of an array into a list.
final def fromIterator[a](it: Iterator[a]): List[a]
     Converts an iterator to a list
final 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.
final def fromString(str: String): List[Char]
     Returns the given string as a list of characters.
final def make[a](n: Int, elem: a): List[a]
     Create a list containing several copies of an element.
final def range(from: Int, end: Int): List[Int]
     Create a sorted list of all integers in a range.
final def range(from: Int, end: Int, step: Int): List[Int]
     Create a sorted list of all integers in a range.
final def range(from: Int, end: Int, step: (Int) => Int): List[Int]
     Create a sorted list of all integers in a range.
final def tabulate[a](n: Int, maker: (Int) => a): List[a]
     Create a list by applying a function to successive integers.
final def toString(xs: List[Char]): String
     Returns the given list of characters as a string.
  def toString(): String
final def unzip[a,b](l: List[Tuple2[a,b]]): Tuple2[List[a],List[b]]
     Transform a list of pair into a pair of lists.
final def view[a](view: (a) => Ordered[a])(x: List[a]): Ordered[List[a]]
     Lists with ordered elements are ordered

Method Detail

apply

  final 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.

range

  final 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).

range

  final 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).

range

  final 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).

make

  final 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

tabulate

  final 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 [0;n).
Returns:
the list obtained by applying the maker function to successive integers from 0 to n (exclusive).

flatten

  final def flatten[a](l: List[List[a]]): List[a]
Concatenate all the elements of a given list of lists.
Parameters:
l - the list of lists that are to be concatenated
Returns:
the concatenation of all the lists

unzip

  final def unzip[a,b](l: List[Tuple2[a,b]]): Tuple2[List[a],List[b]]
Transform a list of pair into a pair of lists.
Parameters:
l - the list of pairs to unzip
Returns:
a pair of lists: the first list in the pair contains the list

fromIterator

  final 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

fromArray

  final 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

fromString

  final 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

fromString

  final 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.

toString

  final 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.

toString

  def toString(): String

view

  final def view[a](view: (a) => Ordered[a])(x: List[a]): Ordered[List[a]]
Lists with ordered elements are ordered