Skip to content

Instantly share code, notes, and snippets.

@Sciss
Created January 13, 2013 00:13
Show Gist options
  • Save Sciss/4521189 to your computer and use it in GitHub Desktop.
Save Sciss/4521189 to your computer and use it in GitHub Desktop.
object Generator {
def apply[A](head: A)(next: A => A) : Generator[A] = Impl(head, next)
private final case class Impl[A](override val head: A, next: A => A)
extends Generator[A] {
protected def underlying = this
}
}
sealed trait Generator[A]
extends IterableView[A, Generator[A]] with IterableViewLike[A, Generator[A], Generator[A]] {
protected def next: A => A
def iterator = Iterator.iterate(head)(next)
trait Transformed[B] extends Generator[B] // with super[IterableViewLike].Transformed[B]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment