Sbequizch12 - codeport/scala GitHub Wiki
-
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
}