Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Override LazyList.range
  • Loading branch information
BalmungSan committed Apr 30, 2024
commit 6de2bf8f9d78df9db95fac1e49dec38105176749
7 changes: 7 additions & 0 deletions src/library/scala/collection/immutable/LazyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,13 @@ final class LazyList[+A] private(private[this] var lazyState: () => LazyList.Sta
*/
@SerialVersionUID(3L)
object LazyList extends SeqFactory[LazyList] {
// Override SeqFactory methods.
override def range[A: Integral](start: A, end: A): LazyList[A] =
range(start, end, step = Integral[A].one)

override def range[A](start: A, end: A, step: A)(implicit ev: Integral[A]): LazyList[A] =
LazyList.iterate(start)(ev.plus(_, step)).takeWhile(ev.lt(_, end))
Comment thread
BalmungSan marked this conversation as resolved.
Outdated
Comment thread
BalmungSan marked this conversation as resolved.
Outdated

// Eagerly evaluate cached empty instance
private[this] val _empty = newLL(State.Empty).force

Expand Down