Packages

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.

  • The definition of fibs is a val not a method. The memoization of the LazyList requires us to have somewhere to store the information and a val allows us to do that.
  • While the LazyList is actually being modified during access, this does not change the notion of its immutability. Once the values are memoized they do not change and values that have yet to be memoized still "exist", they simply haven't been realized yet.
  • One must be cautious of memoization; you can very quickly eat up large amounts of memory if you're not careful. The reason for this is that the memoization of the LazyList creates a structure much like scala.collection.immutable.List. So long as something is holding on to the head, the head holds on to the tail, and so it continues recursively. If, on the other hand, there is nothing holding on to the head (e.g. we used def to define the LazyList) then once it is no longer being used directly, it disappears.
  • Note that some operations, including drop, dropWhile, flatMap or collect may process a large number of intermediate elements before returning. These necessarily hold onto the head, since they are methods on LazyList, and a lazy list holds its own head. For computations of this sort where memoization is not desired, use Iterator when possible.
// 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 fact that tail works at all is of interest. In the definition of fibs we have an initial (0, 1, LazyList(...)) so tail is deterministic. If we defined fibs such that only 0 were concretely known then the act of determining tail would require the evaluation of tail which would cause an infinite recursion and stack overflow. If we define a definition where the tail is not initially computable then we're going to have an infinite recursion:
// 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]
    Attributes
    protected[this]
    Definition Classes
    TraversableLike
  2. class WithFilter extends FilterMonadic[A, Repr]
    Definition Classes
    TraversableLike

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def ++[B >: A, That](suffix: GenTraversableOnce[B])(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    <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

    <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

    <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

    <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 >: A, That](elem: B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    <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
  8. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. def addString(sb: mutable.StringBuilder, start: String, sep: String, end: String): mutable.StringBuilder

    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
  10. def addString(b: StringBuilder): StringBuilder
    Definition Classes
    TraversableOnce
  11. def addString(b: StringBuilder, sep: String): StringBuilder
    Definition Classes
    TraversableOnce
  12. def aggregate[B](z: ⇒ B)(seqop: (B, A) ⇒ B, combop: (B, B) ⇒ B): B
    Definition Classes
    TraversableOnce → GenTraversableOnce
  13. def andThen[C](k: (A) ⇒ C): PartialFunction[Int, C]
    Definition Classes
    PartialFunction → Function1
  14. def apply(n: Int): A
    Definition Classes
    LinearSeqOptimized → SeqLike → GenSeqLike
  15. def applyOrElse[A1 <: Int, B1 >: A](x: A1, default: (A1) ⇒ B1): B1
    Definition Classes
    PartialFunction
  16. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  17. def canEqual(that: Any): Boolean
    Definition Classes
    IterableLike → Equals
  18. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  19. def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

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

    <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()
  21. def combinations(n: Int): Iterator[LazyList[A]]
    Definition Classes
    SeqLike
  22. def companion: GenericCompanion[LazyList]
    Definition Classes
    LazyList → LinearSeq → LinearSeq → Seq → Iterable → Traversable → Seq → GenSeq → Iterable → GenIterable → Traversable → GenTraversable → GenericTraversableTemplate
  23. def compose[A](g: (A) ⇒ Int): (A) ⇒ A
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  24. def contains[A1 >: A](elem: A1): Boolean
    Definition Classes
    LinearSeqOptimized → SeqLike
  25. def containsSlice[B](that: GenSeq[B]): Boolean
    Definition Classes
    SeqLike
  26. def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit
    Definition Classes
    IterableLike → TraversableLike → TraversableOnce → GenTraversableOnce
  27. def copyToArray[B >: A](xs: Array[B]): Unit
    Definition Classes
    TraversableOnce → GenTraversableOnce
  28. def copyToArray[B >: A](xs: Array[B], start: Int): Unit
    Definition Classes
    TraversableOnce → GenTraversableOnce
  29. def copyToBuffer[B >: A](dest: Buffer[B]): Unit
    Definition Classes
    TraversableOnce
  30. final def corresponds[B](that: GenSeq[B])(p: (A, B) ⇒ Boolean): Boolean
    Definition Classes
    LinearSeqLike → SeqLike → GenSeqLike
    Annotations
    @tailrec()
  31. def count(p: (A) ⇒ Boolean): Int
    Definition Classes
    TraversableOnce → GenTraversableOnce
  32. def diff[B >: A](that: GenSeq[B]): LazyList[A]

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  33. def distinct: LazyList[A]
    Definition Classes
    LazyList → SeqLike → GenSeqLike
  34. def distinctBy[B](f: (A) ⇒ B): LazyList[A]
  35. def drop(n: Int): LazyList[A]

    <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
  36. def dropRight(n: Int): LazyList[A]

    <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
  37. def dropWhile(p: (A) ⇒ Boolean): LazyList[A]

    <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
  38. def endsWith[B](that: GenSeq[B]): Boolean
    Definition Classes
    SeqLike → GenSeqLike
  39. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  40. def equals(that: Any): Boolean

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method evaluates all elements of the collection.

    Definition Classes
    LazyList → GenSeqLike → Equals → AnyRef → Any
  41. def exists(p: (A) ⇒ Boolean): Boolean
    Definition Classes
    LinearSeqOptimized → IterableLike → TraversableLike → TraversableOnce → GenTraversableOnce
  42. def filter(pred: (A) ⇒ Boolean): LazyList[A]

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

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

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  44. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  45. def find(p: (A) ⇒ Boolean): Option[A]

    <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()
  46. def flatMap[B, That](f: (A) ⇒ GenTraversableOnce[B])(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

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

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

    Definition Classes
    LazyList → GenericTraversableTemplate
  48. def fold[A1 >: A](z: A1)(op: (A1, A1) ⇒ A1): A1
    Definition Classes
    TraversableOnce → GenTraversableOnce
  49. def foldLeft[B](z: B)(op: (B, A) ⇒ B): B

    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()
  50. def foldRight[B](z: B)(op: (A, B) ⇒ B): B
    Definition Classes
    LinearSeqOptimized → IterableLike → TraversableOnce → GenTraversableOnce
  51. def forall(p: (A) ⇒ Boolean): Boolean
    Definition Classes
    LinearSeqOptimized → IterableLike → TraversableLike → TraversableOnce → GenTraversableOnce
  52. def force: LazyList.this.type

    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

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

    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

    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.

    ,

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

  54. def genericBuilder[B]: Builder[B, LazyList[B]]
    Definition Classes
    GenericTraversableTemplate
  55. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  56. def groupBy[K](f: (A) ⇒ K): immutable.Map[K, LazyList[A]]
    Definition Classes
    TraversableLike → GenTraversableLike
  57. def grouped(size: Int): scala.Iterator[LazyList[A]]

    <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
  58. def hasDefiniteSize: Boolean

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

    Definition Classes
    LazyList → TraversableLike → TraversableOnce → GenTraversableOnce
  59. def hashCode(): Int
    Definition Classes
    LinearSeqLike → GenSeqLike → AnyRef → Any
  60. def head: A
    Definition Classes
    LazyList → LinearSeqOptimized → IterableLike → GenericTraversableTemplate → TraversableLike → GenTraversableLike
  61. def headOption: Option[A]
    Definition Classes
    TraversableLike → GenTraversableLike
  62. def indexOf[B >: A](elem: B, from: Int): Int
    Definition Classes
    GenSeqLike
  63. def indexOf[B >: A](elem: B): Int
    Definition Classes
    GenSeqLike
  64. def indexOfSlice[B >: A](that: GenSeq[B], from: Int): Int
    Definition Classes
    SeqLike
  65. def indexOfSlice[B >: A](that: GenSeq[B]): Int
    Definition Classes
    SeqLike
  66. def indexWhere(p: (A) ⇒ Boolean, from: Int): Int
    Definition Classes
    LinearSeqOptimized → SeqLike → GenSeqLike
  67. def indexWhere(p: (A) ⇒ Boolean): Int
    Definition Classes
    GenSeqLike
  68. def indices: immutable.Range
    Definition Classes
    SeqLike
  69. def init: LazyList[A]
    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  70. def inits: Iterator[LazyList[A]]
    Definition Classes
    TraversableLike
  71. def intersect[B >: A](that: GenSeq[B]): LazyList[A]

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  72. def isDefinedAt(x: Int): Boolean
    Definition Classes
    LinearSeqOptimized → GenSeqLike
  73. def isEmpty: Boolean
    Definition Classes
    LazyList → LinearSeqOptimized → SeqLike → IterableLike → GenericTraversableTemplate → TraversableLike → TraversableOnce → GenTraversableOnce
  74. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  75. final def isTraversableAgain: Boolean
    Definition Classes
    TraversableLike → GenTraversableLike → GenTraversableOnce
  76. def iterator: scala.Iterator[A]

    <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
  77. def knownSize: Int

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

  78. def last: A
    Definition Classes
    LinearSeqOptimized → TraversableLike → GenTraversableLike
  79. def lastIndexOf[B >: A](elem: B, end: Int): Int
    Definition Classes
    GenSeqLike
  80. def lastIndexOf[B >: A](elem: B): Int
    Definition Classes
    GenSeqLike
  81. def lastIndexOfSlice[B >: A](that: GenSeq[B], end: Int): Int
    Definition Classes
    SeqLike
  82. def lastIndexOfSlice[B >: A](that: GenSeq[B]): Int
    Definition Classes
    SeqLike
  83. def lastIndexWhere(p: (A) ⇒ Boolean, end: Int): Int
    Definition Classes
    LinearSeqOptimized → SeqLike → GenSeqLike
  84. def lastIndexWhere(p: (A) ⇒ Boolean): Int
    Definition Classes
    GenSeqLike
  85. def lastOption: Option[A]
    Definition Classes
    TraversableLike → GenTraversableLike
  86. def lazyAppendedAll[B >: A](suffix: ⇒ GenTraversableOnce[B]): LazyList[B]

    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.

  87. def length: Int
    Definition Classes
    LinearSeqOptimized → SeqLike → GenSeqLike
  88. def lengthCompare(len: Int): Int
    Definition Classes
    LinearSeqOptimized → SeqLike
  89. def lift: (Int) ⇒ Option[A]
    Definition Classes
    PartialFunction
  90. def map[B, That](f: (A) ⇒ B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

    Definition Classes
    LazyList → TraversableLike → GenTraversableLike → FilterMonadic
  91. def max[B >: A](implicit cmp: Ordering[B]): A
    Definition Classes
    TraversableOnce → GenTraversableOnce
  92. def maxBy[B](f: (A) ⇒ B)(implicit cmp: Ordering[B]): A
    Definition Classes
    TraversableOnce → GenTraversableOnce
  93. def min[B >: A](implicit cmp: Ordering[B]): A
    Definition Classes
    TraversableOnce → GenTraversableOnce
  94. def minBy[B](f: (A) ⇒ B)(implicit cmp: Ordering[B]): A
    Definition Classes
    TraversableOnce → GenTraversableOnce
  95. def mkString: String
    Definition Classes
    TraversableOnce → GenTraversableOnce
  96. def mkString(sep: String): String
    Definition Classes
    TraversableOnce → GenTraversableOnce
  97. def mkString(start: String, sep: String, end: String): String
    Definition Classes
    TraversableOnce → GenTraversableOnce
  98. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  99. def newBuilder: Builder[A, LazyList[A]]
    Attributes
    protected[this]
    Definition Classes
    GenericTraversableTemplate → HasNewBuilder
  100. def nonEmpty: Boolean
    Definition Classes
    TraversableOnce → GenTraversableOnce
  101. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  102. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  103. def orElse[A1 <: Int, B1 >: A](that: PartialFunction[A1, B1]): PartialFunction[A1, B1]
    Definition Classes
    PartialFunction
  104. def padTo[B >: A, That](len: Int, elem: B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  105. def par: ParSeq[A]
    Definition Classes
    Parallelizable
  106. def parCombiner: Combiner[A, ParSeq[A]]
    Attributes
    protected[this]
    Definition Classes
    Seq → SeqLike → Iterable → TraversableLike → Parallelizable
  107. def partition(p: (A) ⇒ Boolean): (LazyList[A], LazyList[A])

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

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

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

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

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  110. def permutations: Iterator[LazyList[A]]
    Definition Classes
    SeqLike
  111. def prefixLength(p: (A) ⇒ Boolean): Int
    Definition Classes
    GenSeqLike
  112. def product[B >: A](implicit num: Numeric[B]): B
    Definition Classes
    TraversableOnce → GenTraversableOnce
  113. def reduce[A1 >: A](op: (A1, A1) ⇒ A1): A1
    Definition Classes
    TraversableOnce → GenTraversableOnce
  114. def reduceLeft[B >: A](f: (B, A) ⇒ B): B

    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
  115. def reduceLeftOption[B >: A](op: (B, A) ⇒ B): Option[B]
    Definition Classes
    TraversableOnce → GenTraversableOnce
  116. def reduceOption[A1 >: A](op: (A1, A1) ⇒ A1): Option[A1]
    Definition Classes
    TraversableOnce → GenTraversableOnce
  117. def reduceRight[B >: A](op: (A, B) ⇒ B): B
    Definition Classes
    LinearSeqOptimized → IterableLike → TraversableOnce → GenTraversableOnce
  118. def reduceRightOption[B >: A](op: (A, B) ⇒ B): Option[B]
    Definition Classes
    TraversableOnce → GenTraversableOnce
  119. def repr: LazyList[A]
    Definition Classes
    TraversableLike → GenTraversableLike
  120. def reverse: LazyList[A]

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

    This method evaluates all elements of the collection.

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  121. def reverseIterator: Iterator[A]
    Definition Classes
    SeqLike
  122. def reverseMap[B, That](f: (A) ⇒ B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That
    Definition Classes
    SeqLike → GenSeqLike
  123. def reversed: List[A]
    Attributes
    protected[this]
    Definition Classes
    TraversableOnce
  124. def runWith[U](action: (A) ⇒ U): (Int) ⇒ Boolean
    Definition Classes
    PartialFunction
  125. def sameElements[B >: A](that: GenIterable[B]): Boolean
    Definition Classes
    LazyList → LinearSeqOptimized → IterableLike → GenIterableLike
  126. def scan[B >: A, That](z: B)(op: (B, B) ⇒ B)(implicit cbf: CanBuildFrom[LazyList[A], B, That]): That
    Definition Classes
    TraversableLike → GenTraversableLike
  127. def scanLeft[B, That](z: B)(op: (B, A) ⇒ B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  128. def scanRight[B, That](z: B)(op: (A, B) ⇒ B)(implicit bf: CanBuildFrom[LazyList[A], B, That]): That
    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.

  129. def segmentLength(p: (A) ⇒ Boolean, from: Int): Int
    Definition Classes
    LinearSeqOptimized → SeqLike → GenSeqLike
  130. def seq: immutable.LinearSeq[A]
    Definition Classes
    LinearSeq → LinearSeq → LinearSeqLike → Seq → Seq → GenSeq → GenSeqLike → Iterable → Iterable → GenIterable → Traversable → Traversable → GenTraversable → Parallelizable → TraversableOnce → GenTraversableOnce
  131. def size: Int
    Definition Classes
    SeqLike → GenTraversableLike → TraversableOnce → GenTraversableOnce
  132. def sizeHintIfCheap: Int
    Attributes
    protected[collection]
    Definition Classes
    GenTraversableOnce
  133. def slice(from: Int, until: Int): LazyList[A]

    <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
  134. def sliding(size: Int, step: Int): scala.Iterator[LazyList[A]]

    <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
  135. def sliding(size: Int): Iterator[LazyList[A]]
    Definition Classes
    IterableLike
  136. def sortBy[B](f: (A) ⇒ B)(implicit ord: math.Ordering[B]): LazyList[A]
    Definition Classes
    SeqLike
  137. def sortWith(lt: (A, A) ⇒ Boolean): LazyList[A]
    Definition Classes
    SeqLike
  138. def sorted[B >: A](implicit ord: math.Ordering[B]): LazyList[A]
    Definition Classes
    SeqLike
  139. def span(p: (A) ⇒ Boolean): (LazyList[A], LazyList[A])
    Definition Classes
    LazyList → LinearSeqOptimized → TraversableLike → GenTraversableLike
  140. def splitAt(n: Int): (LazyList[A], LazyList[A])
    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  141. def startsWith[B](that: GenSeq[B], offset: Int): Boolean
    Definition Classes
    SeqLike → GenSeqLike
  142. def startsWith[B](that: GenSeq[B]): Boolean
    Definition Classes
    GenSeqLike
  143. def stringPrefix: String
    Definition Classes
    LazyList → TraversableLike → GenTraversableLike
  144. def sum[B >: A](implicit num: Numeric[B]): B
    Definition Classes
    TraversableOnce → GenTraversableOnce
  145. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  146. def tail: LazyList[A]
    Definition Classes
    LazyList → LinearSeqOptimized → TraversableLike → GenTraversableLike
  147. def tails: Iterator[LazyList[A]]
    Definition Classes
    LinearSeqOptimized → TraversableLike
  148. def take(n: Int): LazyList[A]

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

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

    <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
  150. def takeWhile(p: (A) ⇒ Boolean): LazyList[A]

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

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

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

  152. def thisCollection: LinearSeq[A]
    Attributes
    protected[this]
    Definition Classes
    LinearSeqLike → SeqLike → IterableLike → TraversableLike
  153. def to[Col[_]](implicit cbf: CanBuildFrom[Nothing, A, Col[A]]): Col[A]
    Definition Classes
    LazyList → TraversableLike → TraversableOnce → GenTraversableOnce
  154. def toArray[B >: A](implicit arg0: ClassTag[B]): Array[B]
    Definition Classes
    TraversableOnce → GenTraversableOnce
  155. def toBuffer[B >: A]: Buffer[B]
    Definition Classes
    TraversableOnce → GenTraversableOnce
  156. def toCollection(repr: LazyList[A]): LinearSeq[A]
    Attributes
    protected[this]
    Definition Classes
    LinearSeqLike → SeqLike → IterableLike → TraversableLike
  157. def toIndexedSeq: immutable.IndexedSeq[A]
    Definition Classes
    TraversableOnce → GenTraversableOnce
  158. def toIterable: Iterable[A]
    Definition Classes
    IterableLike → TraversableOnce → GenTraversableOnce
  159. def toIterator: Iterator[A]
    Definition Classes
    IterableLike → TraversableLike → GenTraversableOnce
    Annotations
    @deprecatedOverriding( ... , "2.11.0" )
  160. def toList: List[A]
    Definition Classes
    TraversableOnce → GenTraversableOnce
  161. def toMap[T, U](implicit ev: <:<[A, (T, U)]): immutable.Map[T, U]
    Definition Classes
    TraversableOnce → GenTraversableOnce
  162. def toSeq: immutable.Seq[A]
    Definition Classes
    Seq → SeqLike → GenSeqLike → TraversableOnce → GenTraversableOnce
  163. def toSet[B >: A]: immutable.Set[B]
    Definition Classes
    TraversableOnce → GenTraversableOnce
  164. def toStream: immutable.Stream[A]
    Definition Classes
    IterableLike → TraversableLike → GenTraversableOnce
  165. def toString(): String

    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
  166. def toTraversable: Traversable[A]
    Definition Classes
    TraversableLike → TraversableOnce → GenTraversableOnce
    Annotations
    @deprecatedOverriding( ... , "2.11.0" )
  167. def toVector: Vector[A]
    Definition Classes
    TraversableOnce → GenTraversableOnce
  168. def transpose[B](implicit asTraversable: (A) ⇒ GenTraversableOnce[B]): LazyList[LazyList[B]]
    Definition Classes
    GenericTraversableTemplate
    Annotations
    @migration
    Migration

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

  169. def union[B >: A, That](that: GenSeq[B])(implicit bf: CanBuildFrom[LazyList[A], B, That]): That
    Definition Classes
    SeqLike → GenSeqLike
  170. def unzip[A1, A2](implicit asPair: (A) ⇒ (A1, A2)): (LazyList[A1], LazyList[A2])

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

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

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

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

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

    Definition Classes
    LazyList → SeqLike → GenSeqLike
  173. def view(from: Int, until: Int): SeqView[A, LazyList[A]]
    Definition Classes
    SeqLike → IterableLike → TraversableLike
  174. def view: SeqView[A, LazyList[A]]
    Definition Classes
    SeqLike → IterableLike → TraversableLike
  175. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  176. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  177. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  178. def withFilter(p: (A) ⇒ Boolean): FilterMonadic[A, LazyList[A]]

    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
  179. def writeReplace(): AnyRef
    Attributes
    protected[this]
  180. def zip[A1 >: A, B, That](that: GenIterable[B])(implicit bf: CanBuildFrom[LazyList[A], (A1, B), That]): That

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

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

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

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

    <invalid inheritdoc annotation>

    <invalid inheritdoc annotation>

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

    Definition Classes
    LazyList → IterableLike → GenIterableLike

Deprecated Value Members

  1. def /:[B](z: B)(op: (B, A) ⇒ B): B
    Definition Classes
    TraversableOnce → GenTraversableOnce
    Annotations
    @deprecated
    Deprecated

    (Since version 2.12.10) Use foldLeft instead of /:

  2. def :\[B](z: B)(op: (A, B) ⇒ B): B
    Definition Classes
    TraversableOnce → GenTraversableOnce
    Annotations
    @deprecated
    Deprecated

    (Since version 2.12.10) Use foldRight instead of :\

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