We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Stream은 어떤 식으로 lazy evaluation을 수행할 수 있을까요?
Stream과 비슷한 녀석 StreamLike를 만들어 봅시다. (난이도 상)
다음은 Scaladoc의 Stream에 나오는 예제 코드이다. 읽고 이해해보자.
object Main extends Application { def from(n: Int): Stream[Int] = Stream.cons(n, from(n + 1)) def sieve(s: Stream[Int]): Stream[Int] = Stream.cons(s.head, sieve(s.tail filter { _ % s.head != 0 })) def primes = sieve(from(2)) primes take 10 print }