Class/Object

scala.collection.compat.immutable

LazyList

Related Docs: object LazyList | package immutable

Permalink

final class LazyList[+A] extends AbstractSeq[A] with immutable.LinearSeq[A] with GenericTraversableTemplate[A, LazyList] with LinearSeqOptimized[A, LazyList[A]] with Serializable

This class implements an immutable linked list that evaluates elements in order and only when needed. Here is an example:

import scala.math.BigInt
object Main extends App {

  val fibs: LazyList[BigInt] = BigInt(0) #:: BigInt(1) #:: fibs.zip(fibs.tail).map { n => n._1 + n._2 }

  fibs take 5 foreach println
}

// prints
//
// 0
// 1
// 1
// 2
// 3

A LazyList, like the one in the example above, may be infinite in length. Aggregate methods, such as count, sum, max or min on such infinite length sequences will not terminate. Filtered infinite lazy lists are also effectively infinite in length.

Elements of a LazyList are memoized; that is, the value of each element is computed only once. To illustrate, we will alter body of the fibs value above and take some more values:

import scala.math.BigInt
object Main extends App {

  val fibs: LazyList[BigInt] = BigInt(0) #:: BigInt(1) #:: fibs.zip(
    fibs.tail).map(n => {
      println("Adding %d and %d".format(n._1, n._2))
      n._1 + n._2
    })

  fibs take 5 foreach println
  fibs take 6 foreach println
}

// prints
//
// 0
// 1
// Adding 0 and 1
// 1
// Adding 1 and 1
// 2
// Adding 1 and 2
// 3

// And then prints
//
// 0
// 1
// 1
// 2
// 3
// Adding 2 and 3
// 5

There are a number of subtle points to the above example.

// For example, let's build the natural numbers and do some silly iteration
// over them.

// We'll start with a silly iteration
def loop(s: String, i: Int, iter: Iterator[Int]): Unit = {
  // Stop after 200,000
  if (i < 200001) {
    if (i % 50000 == 0) println(s + i)
    loop(s, iter.next(), iter)
  }
}

// Our first LazyList definition will be a val definition
val lazylist1: LazyList[Int] = {
  def loop(v: Int): LazyList[Int] = v #:: loop(v + 1)
  loop(0)
}

// Because lazylist1 is a val, everything that the iterator produces is held
// by virtue of the fact that the head of the LazyList is held in lazylist1
val it1 = lazylist1.toIterator
loop("Iterator1: ", it1.next(), it1)

// We can redefine this LazyList such that all we have is the Iterator left
// and allow the LazyList to be garbage collected as required.  Using a def
// to provide the LazyList ensures that no val is holding onto the head as
// is the case with lazylist1
def lazylist2: LazyList[Int] = {
  def loop(v: Int): LazyList[Int] = v #:: loop(v + 1)
  loop(0)
}
val it2 = lazylist2.toIterator
loop("Iterator2: ", it2.next(), it2)

// And, of course, we don't actually need a LazyList at all for such a simple
// problem.  There's no reason to use a LazyList if you don't actually need
// one.
val it3 = new Iterator[Int] {
  var i = -1
  def hasNext = true
  def next(): Int = { i += 1; i }
}
loop("Iterator3: ", it3.next(), it3)
// The first time we try to access the tail we're going to need more
// information which will require us to recurse, which will require us to
// recurse, which...
lazy val sov: LazyList[Vector[Int]] = Vector(0) #:: sov.zip(sov.tail).map { n => n._1 ++ n._2 }

The definition of fibs above creates a larger number of objects than necessary depending on how you might want to implement it. The following implementation provides a more "cost effective" implementation due to the fact that it has a more direct route to the numbers themselves:

lazy val fib: LazyList[Int] = {
  def loop(h: Int, n: Int): LazyList[Int] = h #:: loop(n, h + n)
  loop(1, 1)
}
A

the type of the elements contained in this lazy list.

Annotations
@SerialVersionUID()
See also

"Scala's Collection Library overview" section on LazyLists for more information.

Linear Supertypes
Serializable, java.io.Serializable, LinearSeqOptimized[A, LazyList[A]], immutable.LinearSeq[A], LinearSeq[A], LinearSeqLike[A, LazyList[A]], immutable.Seq[A], immutable.Iterable[A], immutable.Traversable[A], Immutable, AbstractSeq[A], Seq[A], SeqLike[A, LazyList[A]], GenSeq[A], GenSeqLike[A, LazyList[A]], PartialFunction[Int, A], (Int) ⇒ A, AbstractIterable[A], Iterable[A], IterableLike[A, LazyList[A]], Equals, GenIterable[A], GenIterableLike[A, LazyList[A]], AbstractTraversable[A], Traversable[A], GenTraversable[A], GenericTraversableTemplate[A, LazyList], TraversableLike[A, LazyList[A]], GenTraversableLike[A, LazyList[A]], Parallelizable[A, ParSeq[A]], TraversableOnce[A], GenTraversableOnce[A], FilterMonadic[A, LazyList[A]], HasNewBuilder[A, scala.collection.compat.immutable.LazyList[A] @scala.annotation.unchecked.uncheckedVariance], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. LazyList
  2. Serializable
  3. Serializable
  4. LinearSeqOptimized
  5. LinearSeq
  6. LinearSeq
  7. LinearSeqLike
  8. Seq
  9. Iterable
  10. Traversable
  11. Immutable
  12. AbstractSeq
  13. Seq
  14. SeqLike
  15. GenSeq
  16. GenSeqLike
  17. PartialFunction
  18. Function1
  19. AbstractIterable
  20. Iterable
  21. IterableLike
  22. Equals
  23. GenIterable
  24. GenIterableLike
  25. AbstractTraversable
  26. Traversable
  27. GenTraversable
  28. GenericTraversableTemplate
  29. TraversableLike
  30. GenTraversableLike
  31. Parallelizable
  32. TraversableOnce
  33. GenTraversableOnce
  34. FilterMonadic
  35. HasNewBuilder
  36. AnyRef
  37. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type Self = LazyList[A]

    Permalink
    Attributes
    protected[this]
    Definition Classes
    TraversableLike
  2. class WithFilter extends FilterMonadic[A, Repr]

    Permalink
    Definition Classes
    TraversableLike

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def ++[B >: A, That](suffix: GenTraversableOnce[B])(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Note: Repeated chaining of calls to append methods (appended, appendedAll, lazyAppendedAll) without forcing any of the intermediate resulting lazy lists may overflow the stack when the final result is forced.

    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  4. def ++:[B >: A, That](prefix: scala.Traversable[B])(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → TraversableLike
  5. def ++:[B >: A, That](prefix: scala.TraversableOnce[B])(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → TraversableLike
  6. def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  7. def /:[B](z: B)(op: (B, A) ⇒ B): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  8. def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Note: Repeated chaining of calls to append methods (appended, appendedAll, lazyAppendedAll) without forcing any of the intermediate resulting lazy lists may overflow the stack when the final result is forced.

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  9. def :\[B](z: B)(op: (A, B) ⇒ B): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  10. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  11. def addString(sb: mutable.StringBuilder, start: String, sep: String, end: String): mutable.StringBuilder

    Permalink

    Appends all elements of this lazy list to a string builder using start, end, and separator strings.

    Appends all elements of this lazy list to a string builder using start, end, and separator strings. The written text begins with the string start and ends with the string end. Inside, the string representations (w.r.t. the method toString) of all elements of this lazy list are separated by the string sep.

    An undefined state is represented with "<not computed>" and cycles are represented with "<cycle>".

    This method evaluates all elements of the collection.

    sb

    the string builder to which elements are appended.

    start

    the starting string.

    sep

    the separator string.

    end

    the ending string.

    returns

    the string builder b to which elements were appended.

    Definition Classes
    LazyList → TraversableOnce
  12. def addString(b: StringBuilder): StringBuilder

    Permalink
    Definition Classes
    TraversableOnce
  13. def addString(b: StringBuilder, sep: String): StringBuilder

    Permalink
    Definition Classes
    TraversableOnce
  14. def aggregate[B](z: ⇒ B)(seqop: (B, A) ⇒ B, combop: (B, B) ⇒ B): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  15. def andThen[C](k: (A) ⇒ C): PartialFunction[Int, C]

    Permalink
    Definition Classes
    PartialFunction → Function1
  16. def apply(n: Int): A

    Permalink
    Definition Classes
    LinearSeqOptimized → SeqLike → GenSeqLike
  17. def applyOrElse[A1 <: Int, B1 >: A](x: A1, default: (A1) ⇒ B1): B1

    Permalink
    Definition Classes
    PartialFunction
  18. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  19. def canEqual(that: Any): Boolean

    Permalink
    Definition Classes
    IterableLike → Equals
  20. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  22. def collectFirst[B](pf: PartialFunction[A, B]): Option[B]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method does not evaluate any elements further than the first element for which the partial function is defined.

    Definition Classes
    LazyList → TraversableOnce
    Annotations
    @tailrec()
  23. def combinations(n: Int): Iterator[LazyList[A]]

    Permalink
    Definition Classes
    SeqLike
  24. def companion: GenericCompanion[LazyList]

    Permalink
    Definition Classes
    LazyList → LinearSeq → LinearSeq → Seq → Iterable → Traversable → Seq → GenSeq → Iterable → GenIterable → Traversable → GenTraversable → GenericTraversableTemplate
  25. def compose[A](g: (A) ⇒ Int): (A) ⇒ A

    Permalink
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  26. def contains[A1 >: A](elem: A1): Boolean

    Permalink
    Definition Classes
    LinearSeqOptimized → SeqLike
  27. def containsSlice[B](that: GenSeq[B]): Boolean

    Permalink
    Definition Classes
    SeqLike
  28. def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit

    Permalink
    Definition Classes
    IterableLike → TraversableLike → TraversableOnce → GenTraversableOnce
  29. def copyToArray[B >: A](xs: Array[B]): Unit

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  30. def copyToArray[B >: A](xs: Array[B], start: Int): Unit

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  31. def copyToBuffer[B >: A](dest: Buffer[B]): Unit

    Permalink
    Definition Classes
    TraversableOnce
  32. final def corresponds[B](that: GenSeq[B])(p: (A, B) ⇒ Boolean): Boolean

    Permalink
    Definition Classes
    LinearSeqLike → SeqLike → GenSeqLike
    Annotations
    @tailrec()
  33. def count(p: (A) ⇒ Boolean): Int

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  34. def diff[B >: A](that: GenSeq[B]): LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  35. def distinct: LazyList[A]

    Permalink
    Definition Classes
    LazyList → SeqLike → GenSeqLike
  36. def distinctBy[B](f: (A) ⇒ B): LazyList[A]

    Permalink
  37. def drop(n: Int): LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method does not evaluate anything until an operation is performed on the result (e.g. calling head or tail, or checking if it is empty). Additionally, it preserves laziness for all except the first n elements.

    Definition Classes
    LazyList → LinearSeqOptimized → IterableLike → TraversableLike → GenTraversableLike
  38. def dropRight(n: Int): LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method does not evaluate anything until an operation is performed on the result (e.g. calling head or tail, or checking if it is empty).

    Definition Classes
    LazyList → LinearSeqOptimized → IterableLike
  39. def dropWhile(p: (A) ⇒ Boolean): LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method does not evaluate anything until an operation is performed on the result (e.g. calling head or tail, or checking if it is empty). Additionally, it preserves laziness for all elements after the predicate returns false.

    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  40. def endsWith[B](that: GenSeq[B]): Boolean

    Permalink
    Definition Classes
    SeqLike → GenSeqLike
  41. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  42. def equals(that: Any): Boolean

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method evaluates all elements of the collection.

    Definition Classes
    LazyList → GenSeqLike → Equals → AnyRef → Any
  43. def exists(p: (A) ⇒ Boolean): Boolean

    Permalink
    Definition Classes
    LinearSeqOptimized → IterableLike → TraversableLike → TraversableOnce → GenTraversableOnce
  44. def filter(pred: (A) ⇒ Boolean): LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  45. def filterNot(pred: (A) ⇒ Boolean): LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  46. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  47. def find(p: (A) ⇒ Boolean): Option[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method does not evaluate any elements further than the first element matching the predicate.

    Definition Classes
    LazyList → LinearSeqOptimized → IterableLike → TraversableLike → TraversableOnce → GenTraversableOnce
    Annotations
    @tailrec()
  48. def flatMap[B, That](f: (A) ⇒ GenTraversableOnce[B])(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → TraversableLike → GenTraversableLike → FilterMonadic
  49. def flatten[B](implicit asIterable: (A) ⇒ GenTraversableOnce[B]): LazyList[B]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → GenericTraversableTemplate
  50. def fold[A1 >: A](z: A1)(op: (A1, A1) ⇒ A1): A1

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  51. def foldLeft[B](z: B)(op: (B, A) ⇒ B): B

    Permalink

    LazyList specialization of foldLeft which allows GC to collect along the way.

    LazyList specialization of foldLeft which allows GC to collect along the way.

    B

    The type of value being accumulated.

    z

    The initial value seeded into the function op.

    op

    The operation to perform on successive elements of the LazyList.

    returns

    The accumulated value from successive applications of op.

    Definition Classes
    LazyList → LinearSeqOptimized → TraversableOnce → GenTraversableOnce
    Annotations
    @tailrec()
  52. def foldRight[B](z: B)(op: (A, B) ⇒ B): B

    Permalink
    Definition Classes
    LinearSeqOptimized → IterableLike → TraversableOnce → GenTraversableOnce
  53. def forall(p: (A) ⇒ Boolean): Boolean

    Permalink
    Definition Classes
    LinearSeqOptimized → IterableLike → TraversableLike → TraversableOnce → GenTraversableOnce
  54. def force: LazyList.this.type

    Permalink

    Evaluates all undefined elements of the lazy list.

    Evaluates all undefined elements of the lazy list.

    This method detects cycles in lazy lists, and terminates after all elements of the cycle are evaluated. For example:

    val ring: LazyList[Int] = 1 #:: 2 #:: 3 #:: ring
    ring.force
    ring.toString
    
    // prints
    //
    // LazyList(1, 2, 3, ...)

    This method will *not* terminate for non-cyclic infinite-sized collections.

    returns

    this

  55. def foreach[U](f: (A) ⇒ U): Unit

    Permalink

    Apply the given function f to each element of this linear sequence (while respecting the order of the elements).

    Apply the given function f to each element of this linear sequence (while respecting the order of the elements).

    f

    The treatment to apply to each element.

    Definition Classes
    LazyList → LinearSeqOptimized → IterableLike → GenericTraversableTemplate → TraversableLike → GenTraversableLike → TraversableOnce → GenTraversableOnce → FilterMonadic
    Annotations
    @tailrec()
    Note

    This function will force the realization of the entire LazyList unless the f throws an exception.

    ,

    Overridden here as final to trigger tail-call optimization, which replaces 'this' with 'tail' at each iteration. This is absolutely necessary for allowing the GC to collect the underlying LazyList as elements are consumed.

  56. def genericBuilder[B]: Builder[B, LazyList[B]]

    Permalink
    Definition Classes
    GenericTraversableTemplate
  57. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  58. def groupBy[K](f: (A) ⇒ K): immutable.Map[K, LazyList[A]]

    Permalink
    Definition Classes
    TraversableLike → GenTraversableLike
  59. def grouped(size: Int): scala.Iterator[LazyList[A]]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    The iterator returned by this method mostly preserves laziness; a single element ahead of the iterator is evaluated.

    Definition Classes
    LazyList → IterableLike
  60. def hasDefiniteSize: Boolean

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → TraversableLike → TraversableOnce → GenTraversableOnce
  61. def hashCode(): Int

    Permalink
    Definition Classes
    LinearSeqLike → GenSeqLike → AnyRef → Any
  62. def head: A

    Permalink
    Definition Classes
    LazyList → LinearSeqOptimized → IterableLike → GenericTraversableTemplate → TraversableLike → GenTraversableLike
  63. def headOption: Option[A]

    Permalink
    Definition Classes
    TraversableLike → GenTraversableLike
  64. def indexOf[B >: A](elem: B, from: Int): Int

    Permalink
    Definition Classes
    GenSeqLike
  65. def indexOf[B >: A](elem: B): Int

    Permalink
    Definition Classes
    GenSeqLike
  66. def indexOfSlice[B >: A](that: GenSeq[B], from: Int): Int

    Permalink
    Definition Classes
    SeqLike
  67. def indexOfSlice[B >: A](that: GenSeq[B]): Int

    Permalink
    Definition Classes
    SeqLike
  68. def indexWhere(p: (A) ⇒ Boolean, from: Int): Int

    Permalink
    Definition Classes
    LinearSeqOptimized → SeqLike → GenSeqLike
  69. def indexWhere(p: (A) ⇒ Boolean): Int

    Permalink
    Definition Classes
    GenSeqLike
  70. def indices: immutable.Range

    Permalink
    Definition Classes
    SeqLike
  71. def init: LazyList[A]

    Permalink
    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  72. def inits: Iterator[LazyList[A]]

    Permalink
    Definition Classes
    TraversableLike
  73. def intersect[B >: A](that: GenSeq[B]): LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  74. def isDefinedAt(x: Int): Boolean

    Permalink
    Definition Classes
    LinearSeqOptimized → GenSeqLike
  75. def isEmpty: Boolean

    Permalink
    Definition Classes
    LazyList → LinearSeqOptimized → SeqLike → IterableLike → GenericTraversableTemplate → TraversableLike → TraversableOnce → GenTraversableOnce
  76. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  77. final def isTraversableAgain: Boolean

    Permalink
    Definition Classes
    TraversableLike → GenTraversableLike → GenTraversableOnce
  78. def iterator: scala.Iterator[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    The iterator returned by this method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → LinearSeqLike → IterableLike → GenIterableLike
  79. def knownSize: Int

    Permalink

    This method preserves laziness; elements are only evaluated individually as needed.

  80. def last: A

    Permalink
    Definition Classes
    LinearSeqOptimized → TraversableLike → GenTraversableLike
  81. def lastIndexOf[B >: A](elem: B, end: Int): Int

    Permalink
    Definition Classes
    GenSeqLike
  82. def lastIndexOf[B >: A](elem: B): Int

    Permalink
    Definition Classes
    GenSeqLike
  83. def lastIndexOfSlice[B >: A](that: GenSeq[B], end: Int): Int

    Permalink
    Definition Classes
    SeqLike
  84. def lastIndexOfSlice[B >: A](that: GenSeq[B]): Int

    Permalink
    Definition Classes
    SeqLike
  85. def lastIndexWhere(p: (A) ⇒ Boolean, end: Int): Int

    Permalink
    Definition Classes
    LinearSeqOptimized → SeqLike → GenSeqLike
  86. def lastIndexWhere(p: (A) ⇒ Boolean): Int

    Permalink
    Definition Classes
    GenSeqLike
  87. def lastOption: Option[A]

    Permalink
    Definition Classes
    TraversableLike → GenTraversableLike
  88. def lazyAppendedAll[B >: A](suffix: ⇒ GenTraversableOnce[B]): LazyList[B]

    Permalink

    The lazy list resulting from the concatenation of this lazy list with the argument lazy list.

    The lazy list resulting from the concatenation of this lazy list with the argument lazy list.

    This method preserves laziness; elements are only evaluated individually as needed.

    Note: Repeated chaining of calls to append methods (appended, appendedAll, lazyAppendedAll) without forcing any of the intermediate resulting lazy lists may overflow the stack when the final result is forced.

    suffix

    The collection that gets appended to this lazy list

    returns

    The lazy list containing elements of this lazy list and the iterable object.

  89. def length: Int

    Permalink
    Definition Classes
    LinearSeqOptimized → SeqLike → GenSeqLike
  90. def lengthCompare(len: Int): Int

    Permalink
    Definition Classes
    LinearSeqOptimized → SeqLike
  91. def lift: (Int) ⇒ Option[A]

    Permalink
    Definition Classes
    PartialFunction
  92. def map[B, That](f: (A) ⇒ B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → TraversableLike → GenTraversableLike → FilterMonadic
  93. def max[B >: A](implicit cmp: Ordering[B]): A

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  94. def maxBy[B](f: (A) ⇒ B)(implicit cmp: Ordering[B]): A

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  95. def min[B >: A](implicit cmp: Ordering[B]): A

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  96. def minBy[B](f: (A) ⇒ B)(implicit cmp: Ordering[B]): A

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  97. def mkString: String

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  98. def mkString(sep: String): String

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  99. def mkString(start: String, sep: String, end: String): String

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  100. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  101. def newBuilder: Builder[A, LazyList[A]]

    Permalink
    Attributes
    protected[this]
    Definition Classes
    GenericTraversableTemplate → HasNewBuilder
  102. def nonEmpty: Boolean

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  103. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  104. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  105. def orElse[A1 <: Int, B1 >: A](that: PartialFunction[A1, B1]): PartialFunction[A1, B1]

    Permalink
    Definition Classes
    PartialFunction
  106. def padTo[B >: A, That](len: Int, elem: B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  107. def par: ParSeq[A]

    Permalink
    Definition Classes
    Parallelizable
  108. def parCombiner: Combiner[A, ParSeq[A]]

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Seq → SeqLike → Iterable → TraversableLike → Parallelizable
  109. def partition(p: (A) ⇒ Boolean): (LazyList[A], LazyList[A])

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  110. def partitionMap[A1, A2](f: (A) ⇒ Either[A1, A2]): (LazyList[A1], LazyList[A2])

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

  111. def patch[B >: A, That](from: Int, other: GenSeq[B], replaced: Int)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  112. def permutations: Iterator[LazyList[A]]

    Permalink
    Definition Classes
    SeqLike
  113. def prefixLength(p: (A) ⇒ Boolean): Int

    Permalink
    Definition Classes
    GenSeqLike
  114. def product[B >: A](implicit num: Numeric[B]): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  115. def reduce[A1 >: A](op: (A1, A1) ⇒ A1): A1

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  116. def reduceLeft[B >: A](f: (B, A) ⇒ B): B

    Permalink

    LazyList specialization of reduceLeft which allows GC to collect along the way.

    LazyList specialization of reduceLeft which allows GC to collect along the way.

    B

    The type of value being accumulated.

    f

    The operation to perform on successive elements of the LazyList.

    returns

    The accumulated value from successive applications of f.

    Definition Classes
    LazyList → LinearSeqOptimized → TraversableOnce
  117. def reduceLeftOption[B >: A](op: (B, A) ⇒ B): Option[B]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  118. def reduceOption[A1 >: A](op: (A1, A1) ⇒ A1): Option[A1]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  119. def reduceRight[B >: A](op: (A, B) ⇒ B): B

    Permalink
    Definition Classes
    LinearSeqOptimized → IterableLike → TraversableOnce → GenTraversableOnce
  120. def reduceRightOption[B >: A](op: (A, B) ⇒ B): Option[B]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  121. def repr: LazyList[A]

    Permalink
    Definition Classes
    TraversableLike → GenTraversableLike
  122. def reverse: LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method evaluates all elements of the collection.

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  123. def reverseIterator: Iterator[A]

    Permalink
    Definition Classes
    SeqLike
  124. def reverseMap[B, That](f: (A) ⇒ B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink
    Definition Classes
    SeqLike → GenSeqLike
  125. def reversed: List[A]

    Permalink
    Attributes
    protected[this]
    Definition Classes
    TraversableOnce
  126. def runWith[U](action: (A) ⇒ U): (Int) ⇒ Boolean

    Permalink
    Definition Classes
    PartialFunction
  127. def sameElements[B >: A](that: GenIterable[B]): Boolean

    Permalink
    Definition Classes
    LazyList → LinearSeqOptimized → IterableLike → GenIterableLike
  128. def scan[B >: A, That](z: B)(op: (B, B) ⇒ B)(implicit cbf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink
    Definition Classes
    TraversableLike → GenTraversableLike
  129. def scanLeft[B, That](z: B)(op: (B, A) ⇒ B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  130. def scanRight[B, That](z: B)(op: (A, B) ⇒ B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink
    Definition Classes
    TraversableLike → GenTraversableLike
    Annotations
    @migration
    Migration

    (Changed in version 2.9.0) The behavior of scanRight has changed. The previous behavior can be reproduced with scanRight.reverse.

  131. def segmentLength(p: (A) ⇒ Boolean, from: Int): Int

    Permalink
    Definition Classes
    LinearSeqOptimized → SeqLike → GenSeqLike
  132. def seq: immutable.LinearSeq[A]

    Permalink
    Definition Classes
    LinearSeq → LinearSeq → LinearSeqLike → Seq → Seq → GenSeq → GenSeqLike → Iterable → Iterable → GenIterable → Traversable → Traversable → GenTraversable → Parallelizable → TraversableOnce → GenTraversableOnce
  133. def size: Int

    Permalink
    Definition Classes
    SeqLike → GenTraversableLike → TraversableOnce → GenTraversableOnce
  134. def slice(from: Int, until: Int): LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method does not evaluate anything until an operation is performed on the result (e.g. calling head or tail, or checking if it is empty). Additionally, it preserves laziness for all but the first from elements.

    Definition Classes
    LazyList → LinearSeqOptimized → IterableLike → TraversableLike → GenTraversableLike
  135. def sliding(size: Int, step: Int): scala.Iterator[LazyList[A]]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    The iterator returned by this method mostly preserves laziness; size - step max 1 elements ahead of the iterator are evaluated.

    Definition Classes
    LazyList → IterableLike
  136. def sliding(size: Int): Iterator[LazyList[A]]

    Permalink
    Definition Classes
    IterableLike
  137. def sortBy[B](f: (A) ⇒ B)(implicit ord: math.Ordering[B]): LazyList[A]

    Permalink
    Definition Classes
    SeqLike
  138. def sortWith(lt: (A, A) ⇒ Boolean): LazyList[A]

    Permalink
    Definition Classes
    SeqLike
  139. def sorted[B >: A](implicit ord: math.Ordering[B]): LazyList[A]

    Permalink
    Definition Classes
    SeqLike
  140. def span(p: (A) ⇒ Boolean): (LazyList[A], LazyList[A])

    Permalink
    Definition Classes
    LazyList → LinearSeqOptimized → TraversableLike → GenTraversableLike
  141. def splitAt(n: Int): (LazyList[A], LazyList[A])

    Permalink
    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  142. def startsWith[B](that: GenSeq[B], offset: Int): Boolean

    Permalink
    Definition Classes
    SeqLike → GenSeqLike
  143. def startsWith[B](that: GenSeq[B]): Boolean

    Permalink
    Definition Classes
    GenSeqLike
  144. def stringPrefix: String

    Permalink
    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  145. def sum[B >: A](implicit num: Numeric[B]): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  146. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  147. def tail: LazyList[A]

    Permalink
    Definition Classes
    LazyList → LinearSeqOptimized → TraversableLike → GenTraversableLike
  148. def tails: Iterator[LazyList[A]]

    Permalink
    Definition Classes
    TraversableLike
  149. def take(n: Int): LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → LinearSeqOptimized → IterableLike → TraversableLike → GenTraversableLike
  150. def takeRight(n: Int): LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method does not evaluate anything until an operation is performed on the result (e.g. calling head or tail, or checking if it is empty).

    Definition Classes
    LazyList → IterableLike
  151. def takeWhile(p: (A) ⇒ Boolean): LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → LinearSeqOptimized → IterableLike → TraversableLike → GenTraversableLike
  152. def tapEach[U](f: (A) ⇒ U): LazyList[A]

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

  153. def thisCollection: LinearSeq[A]

    Permalink
    Attributes
    protected[this]
    Definition Classes
    LinearSeqLike → SeqLike → IterableLike → TraversableLike
  154. def to[Col[_]](implicit cbf: CanBuildFrom[Nothing, A, Col[A]]): Col[A]

    Permalink
    Definition Classes
    LazyList → TraversableLike → TraversableOnce → GenTraversableOnce
  155. def toArray[B >: A](implicit arg0: ClassTag[B]): Array[B]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  156. def toBuffer[B >: A]: Buffer[B]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  157. def toCollection(repr: LazyList[A]): LinearSeq[A]

    Permalink
    Attributes
    protected[this]
    Definition Classes
    LinearSeqLike → SeqLike → IterableLike → TraversableLike
  158. def toIndexedSeq: immutable.IndexedSeq[A]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  159. def toIterable: Iterable[A]

    Permalink
    Definition Classes
    IterableLike → TraversableOnce → GenTraversableOnce
  160. def toIterator: Iterator[A]

    Permalink
    Definition Classes
    IterableLike → TraversableLike → GenTraversableOnce
    Annotations
    @deprecatedOverriding( ... , "2.11.0" )
  161. def toList: List[A]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  162. def toMap[T, U](implicit ev: <:<[A, (T, U)]): immutable.Map[T, U]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  163. def toSeq: immutable.Seq[A]

    Permalink
    Definition Classes
    Seq → SeqLike → GenSeqLike → TraversableOnce → GenTraversableOnce
  164. def toSet[B >: A]: immutable.Set[B]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  165. def toStream: immutable.Stream[A]

    Permalink
    Definition Classes
    IterableLike → TraversableLike → GenTraversableOnce
  166. def toString(): String

    Permalink

    This method preserves laziness; elements are only evaluated individually as needed.

    This method preserves laziness; elements are only evaluated individually as needed.

    returns

    a string representation of this collection. An undefined state is represented with "<not computed>" and cycles are represented with "<cycle>" Examples:

    • "LazyList(4, <not computed>)", a non-empty lazy list ;
    • "LazyList(1, 2, 3, <not computed>)", a lazy list with at least three elements ;
    • "LazyList(1, 2, 3, <cycle>)", an infinite lazy list that contains a cycle at the fourth element.
    Definition Classes
    LazyList → SeqLike → Function1 → TraversableLike → AnyRef → Any
  167. def toTraversable: Traversable[A]

    Permalink
    Definition Classes
    TraversableLike → TraversableOnce → GenTraversableOnce
    Annotations
    @deprecatedOverriding( ... , "2.11.0" )
  168. def toVector: Vector[A]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  169. def transpose[B](implicit asTraversable: (A) ⇒ GenTraversableOnce[B]): LazyList[LazyList[B]]

    Permalink
    Definition Classes
    GenericTraversableTemplate
    Annotations
    @migration
    Migration

    (Changed in version 2.9.0) transpose throws an IllegalArgumentException if collections are not uniformly sized.

  170. def union[B >: A, That](that: GenSeq[B])(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink
    Definition Classes
    SeqLike → GenSeqLike
  171. def unzip[A1, A2](implicit asPair: (A) ⇒ (A1, A2)): (LazyList[A1], LazyList[A2])

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → GenericTraversableTemplate
  172. def unzip3[A1, A2, A3](implicit asTriple: (A) ⇒ (A1, A2, A3)): (LazyList[A1], LazyList[A2], LazyList[A3])

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → GenericTraversableTemplate
  173. def updated[B >: A, That](index: Int, elem: B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  174. def view(from: Int, until: Int): SeqView[A, LazyList[A]]

    Permalink
    Definition Classes
    SeqLike → IterableLike → TraversableLike
  175. def view: SeqView[A, LazyList[A]]

    Permalink
    Definition Classes
    SeqLike → IterableLike → TraversableLike
  176. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  177. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  178. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  179. def withFilter(p: (A) ⇒ Boolean): FilterMonadic[A, LazyList[A]]

    Permalink

    A collection.WithFilter which allows GC of the head of lazy list during processing.

    A collection.WithFilter which allows GC of the head of lazy list during processing.

    This method is not particularly useful for a lazy list, as filter already preserves laziness.

    The collection.WithFilter returned by this method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → TraversableLike → FilterMonadic
  180. def writeReplace(): AnyRef

    Permalink
    Attributes
    protected[this]
  181. def zip[A1 >: A, B, That](that: GenIterable[B])(implicit bf: CanBuildFrom[LazyList[A], (A1, B), That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → IterableLike → GenIterableLike
  182. def zipAll[B, A1 >: A, That](that: GenIterable[B], thisElem: A1, thatElem: B)(implicit bf: CanBuildFrom[LazyList[A], (A1, B), That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → IterableLike → GenIterableLike
  183. def zipWithIndex[A1 >: A, That](implicit bf: CanBuildFrom[LazyList[A], (A1, Int), That]): That

    Permalink

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method preserves laziness; elements are only evaluated individually as needed.

    Definition Classes
    LazyList → IterableLike → GenIterableLike

Inherited from Serializable

Inherited from java.io.Serializable

Inherited from LinearSeqOptimized[A, LazyList[A]]

Inherited from immutable.LinearSeq[A]

Inherited from LinearSeq[A]

Inherited from LinearSeqLike[A, LazyList[A]]

Inherited from immutable.Seq[A]

Inherited from immutable.Iterable[A]

Inherited from immutable.Traversable[A]

Inherited from Immutable

Inherited from AbstractSeq[A]

Inherited from Seq[A]

Inherited from SeqLike[A, LazyList[A]]

Inherited from GenSeq[A]

Inherited from GenSeqLike[A, LazyList[A]]

Inherited from PartialFunction[Int, A]

Inherited from (Int) ⇒ A

Inherited from AbstractIterable[A]

Inherited from Iterable[A]

Inherited from IterableLike[A, LazyList[A]]

Inherited from Equals

Inherited from GenIterable[A]

Inherited from GenIterableLike[A, LazyList[A]]

Inherited from AbstractTraversable[A]

Inherited from Traversable[A]

Inherited from GenTraversable[A]

Inherited from GenericTraversableTemplate[A, LazyList]

Inherited from TraversableLike[A, LazyList[A]]

Inherited from GenTraversableLike[A, LazyList[A]]

Inherited from Parallelizable[A, ParSeq[A]]

Inherited from TraversableOnce[A]

Inherited from GenTraversableOnce[A]

Inherited from FilterMonadic[A, LazyList[A]]

Inherited from HasNewBuilder[A, scala.collection.compat.immutable.LazyList[A] @scala.annotation.unchecked.uncheckedVariance]

Inherited from AnyRef

Inherited from Any

Ungrouped