Skip to content

Instantly share code, notes, and snippets.

@bobpace
Last active January 2, 2016 18:59
Show Gist options
  • Save bobpace/8347385 to your computer and use it in GitHub Desktop.
Save bobpace/8347385 to your computer and use it in GitHub Desktop.
streams
lazy val primes: Stream[Int] =
2 #:: Stream.from(3).filter(n => primes.takeWhile(p => p * p <= n).forall(p => n % p > 0))
lazy val fib: Stream[BigInt] = 0 #:: 1 #:: fib.zip(fib.tail).map { case(x,y) => x + y }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment