|
Scala
1.2.0.1 |
|||
a
. This class comes with two implementing case
classes scala.Nil
and scala.::
that
implement the abstract members isEmpty
,
head
and tail
.
Method Summary | |
def ::[b >: a](x: b): List[b]
Add an element x at the beginning of this list.
|
|
def :::[b >: a](prefix: List[b]): List[b]
Returns a list resulting from the concatenation of the given list prefix and this list.
|
|
def apply(n: Int): a
Returns the n -th element of this list.
|
|
def break(p: (a) => Boolean): Tuple2[List[a],List[a]]
Like span but with the predicate inverted.
|
|
def contains(elem: Any): Boolean
Tests if the given value elem is a member of this list.
|
|
def count(p: (a) => Boolean): Int
Count the number of elements in the list which satisfy a predicate. |
|
def diff[b >: a](that: List[b]): List[b]
Computes the difference between this list and the given list that .
|
|
override
|
def drop(n: Int): List[a]
Returns the list without its n first elements.
|
def dropRight(n: Int): List[a]
Returns the list wihout its rightmost n elements.
|
|
def dropWhile(p: (a) => Boolean): List[a]
Returns the longest suffix of this list whose first element does not satisfy the predicate p .
|
|
def elements: Iterator[a]
Returns the elements in the list as an iterator |
|
override
|
def exists(p: (a) => Boolean): Boolean
Tests the existence in this list of an element that satisfies the predicate p .
|
def filter(p: (a) => Boolean): List[a]
Returns all the elements of this list that satisfy the predicate p .
|
|
override
|
def find(p: (a) => Boolean): Option[a]
Find and return the first element of the list satisfying a predicate, if any. |
def flatMap[b](f: (a) => List[b]): List[b]
Applies the given function f to each element of
this list, then concatenates the results.
|
|
override
|
def foldLeft[b](z: b)(f: (b,a) => b): b
Combines the elements of this list together using the binary operator op , from left to right, and starting with
the value z .
|
override
|
def foldRight[b](z: b)(f: (a,b) => b): b
Combines the elements of this list together using the binary operator op , from rigth to left, and starting with
the value z .
|
override
|
def forall(p: (a) => Boolean): Boolean
Tests if the predicate p is satisfied by all elements
in this list.
|
override
|
def foreach(f: (a) => Unit): Unit
Apply the given function f to each element of this list
(while respecting the order of the elements).
|
abstract
|
def head: a
Returns this first element of the list. |
def indices: List[Int]
Creates a list with all indices in the list. |
|
def init: List[a]
Returns the list without its last element. |
|
def intersect[b >: a](that: List[b]): List[b]
Computes the intersection between this list and the given list that .
|
|
abstract
|
def isEmpty: Boolean
Returns true if the list does not contain any elements. |
def last: a
Returns the last element of this list. |
|
def length: Int
Returns the number of elements in the list. |
|
def map[b](f: (a) => b): List[b]
Returns the list resulting from applying the given function f to each
element of this list.
|
|
def mkString(start: String, sep: String, end: String): String
Returns a string representation of this list. |
|
def partition(p: (a) => Boolean): Tuple2[List[a],List[a]]
Partition the list in two sub-lists according to a predicate. |
|
def reduceLeft[b >: a](f: (b,b) => b): b
|
|
def reduceRight[b >: a](f: (b,b) => b): b
|
|
def remove(p: (a) => Boolean): List[a]
Remove all elements of the list which satisfy the predicate p .
|
|
def removeDuplicates: List[a]
Removes redundant elements from the list. |
|
def reverse: List[a]
Reverses the elements of this list. |
|
def reverseMap[b](f: (a) => b): List[b]
Apply a function to all the elements of the list, and return the reversed list of results. |
|
def reverse_:::[b >: a](prefix: List[b]): List[b]
Reverse the given prefix and append the current list to that. |
|
def sort(lt: (a,a) => Boolean): List[a]
Sort the list according to the comparison function <(e1: a, e2: a) => Boolean ,
which should be true iff e1 is smaller than e2.
|
|
def span(p: (a) => Boolean): Tuple2[List[a],List[a]]
Returns the longest prefix of the list whose elements all satisfy the given predicate, and the rest of the list. |
|
def splitAt(n: Int): Tuple2[List[a],List[a]]
Split the list at a given point and return the two parts thus created. |
|
abstract
|
def tail: List[a]
Returns this list without its first element. |
override
|
def take(n: Int): List[a]
Returns the n first elements of this list.
|
def takeRight(n: Int): List[a]
Returns the rightmost n elements from this list.
|
|
def takeWhile(p: (a) => Boolean): List[a]
Returns the longest prefix of this list whose elements satisfy the predicate p .
|
|
override
|
def toString(): String
Customizes the toString method.
|
def union[b >: a](that: List[b]): List[b]
Computes the union of this list and the given list that .
|
|
def zip[b](that: List[b]): List[Tuple2[a,b]]
Return a list formed from this list and the specified list that by associating each element of the former with
the element at the same position in the latter.
|
Methods inherited from java/lang/Object-class |
clone, eq, equals, finalize, getClass, hashCode, notify, notifyAll, synchronized, wait, wait, wait |
Methods inherited from scala/Any-class |
!=, ==, asInstanceOf, isInstanceOf, match |
Methods inherited from scala/Iterable-class |
/:, :\, sameElements |
Methods inherited from scala/Seq-class |
copyToArray, indexOf, isDefinedAt, lastIndexOf, stringPrefix, subseq, toList |
Method Detail |
abstract def isEmpty: Boolean
abstract def head: a
java.lang.RuntimeException
if the list is empty.
abstract def tail: List[a]
java.lang.RuntimeException
if the list is empty.
def ::[b >: a](x: b): List[b]
x
at the beginning of this list.
Ex:1 :: [2, 3] = [2, 3].::(1) = [1, 2, 3]
.x
-
the element to append.
x
appended at the beginning.
def :::[b >: a](prefix: List[b]): List[b]
prefix
and this list.
Ex:[1, 2] ::: [3, 4] = [3, 4].:::([1, 2]) = [1, 2, 3, 4]
.prefix
-
the list to concatenate at the beginning of this list.
def reverse_:::[b >: a](prefix: List[b]): List[b]
reverse
on the prefix followed by a call to :::
, but more
efficient (and tail recursive).prefix
-
the prefix to reverse and then prepend
def length: Int
def indices: List[Int]
List.range(0, xs.length)
.
def elements: Iterator[a]
def init: List[a]
java.lang.RuntimeException
if the list is empty.
def last: a
java.lang.RuntimeException
if the list is empty.
override def take(n: Int): List[a]
n
first elements of this list.
n
-
the number of elements to take.
n
first elements of this list.java.lang.RuntimeException
if the list is too short.
override def drop(n: Int): List[a]
n
first elements.
n
-
the number of elements to drop.
n
first elements.java.lang.RuntimeException
if the list is too short.
def takeRight(n: Int): List[a]
n
elements from this list.
n
-
the number of elements to take
n
of the listjava.lang.RuntimeException
if the list is too short.
def dropRight(n: Int): List[a]
n
elements.
n
-
the number of elements to take
n
of the listjava.lang.RuntimeException
if the list is too short.
def splitAt(n: Int): Tuple2[List[a],List[a]]
n
-
the position at which to split
n
elements, and the other elements.
def takeWhile(p: (a) => Boolean): List[a]
p
.
p
-
the test predicate.
p
.
def dropWhile(p: (a) => Boolean): List[a]
p
.
p
-
the test predicate.
p
.
def span(p: (a) => Boolean): Tuple2[List[a],List[a]]
p
-
the test predicate
p
, and the rest of the list.
def break(p: (a) => Boolean): Tuple2[List[a],List[a]]
span
but with the predicate inverted.
def apply(n: Int): a
n
-th element of this list. The first element
(head of the list) is at position 0.
n
-
index of the element to return
n
in this list.java.lang.RuntimeException
if the list is too short.
def map[b](f: (a) => b): List[b]
f
to each
element of this list.
f
-
function to apply to each element.
[f(a0), ..., f(an)]
if this list is [a0, ..., an]
.
def reverseMap[b](f: (a) => b): List[b]
map
followed by a call to reverse
, but more efficient.
f
-
the function to apply to each elements.
override def foreach(f: (a) => Unit): Unit
f
to each element of this list
(while respecting the order of the elements).
f
-
the treatment to apply to each element.
def filter(p: (a) => Boolean): List[a]
p
. The order of the elements is preserved.
p
-
the redicate used to filter the list.
p
.
def remove(p: (a) => Boolean): List[a]
p
. This is like filter
with the
predicate inversed.
p
-
the predicate to use to test elements
p
def partition(p: (a) => Boolean): Tuple2[List[a],List[a]]
p
-
the predicate on which to partition
p
and the list of all elements which do not. The
relative order of the elements in the sub-lists is the same as in
the original list.
def sort(lt: (a,a) => Boolean): List[a]
<(e1: a, e2: a) => Boolean
,
which should be true iff e1 is smaller than e2.
Note: The current implementation is inefficent for
already sorted lists.
lt
-
the comparison function
<(e1: a, e2: a) => Boolean
.
def count(p: (a) => Boolean): Int
p
-
the predicate for which to count
p
.
override def forall(p: (a) => Boolean): Boolean
p
is satisfied by all elements
in this list.
p
-
the test predicate.
p
.
override def exists(p: (a) => Boolean): Boolean
p
.
p
-
the test predicate.
p
.
override def find(p: (a) => Boolean): Option[a]
p
-
the predicate
p
,
or None
if none exists.
override def foldLeft[b](z: b)(f: (b,a) => b): b
op
, from left to right, and starting with
the value z
.
op(... (op(op(z,a0),a1) ...), an)
if the list
is [a0, a1, ..., an]
.
override def foldRight[b](z: b)(f: (a,b) => b): b
op
, from rigth to left, and starting with
the value z
.
a0 op (... op (an op z)...)
if the list
is [a0, a1, ..., an]
.
def reduceLeft[b >: a](f: (b,b) => b): b
def reduceRight[b >: a](f: (b,b) => b): b
def flatMap[b](f: (a) => List[b]): List[b]
f
to each element of
this list, then concatenates the results.
f
-
the function to apply on each element.
f(a0) ::: ... ::: f(an)
if this list is
[a0, ..., an]
.
def reverse: List[a]
[1, 2, 3] reverse = [3, 2, 1]
.
def mkString(start: String, sep: String, end: String): String
start
and is finished by the string
end
. Inside, the string representations of elements (w.r.t.
the method toString()
) are separated by the string
sep
.
Ex: List(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)"
start
-
starting string.
sep
-
separator string.
end
-
ending string.
override def toString(): String
toString
method.
def zip[b](that: List[b]): List[Tuple2[a,b]]
that
by associating each element of the former with
the element at the same position in the latter.
that
-
must have the same length as the self list.
[(a0,b0), ..., (an,bn)]
when
[a0, ..., an] zip [b0, ..., bn]
is invoked.
def contains(elem: Any): Boolean
elem
is a member of this list.
elem
-
element whose membership has to be tested.
==
) to elem
.
def union[b >: a](that: List[b]): List[b]
that
.
that
-
the list of elements to add to the list.
that
.
def diff[b >: a](that: List[b]): List[b]
that
.
that
-
the list of elements to remove from this list.
that
.
def intersect[b >: a](that: List[b]): List[b]
that
.
that
-
the list to intersect.
that
.
def removeDuplicates: List[a]
==
to decide if two elements are identical.
|
Scala
1.2.0.1 |
|||