Slide 51
Slide 51 text
【活用例】計算結果による分岐
def fizzBuzz(i: Int): Cont[String, Int] =
for {
a <- fizzBuzzCont(i)
b <- fizzCont(a)
c <- buzzCont(b)
} yield c
scala> LazyList.from(1).map(fizzBuzz(_).run(_.toString)).take(15).toList
res54: List[String] = List(1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11,
Fizz, 13, 14, FizzBuzz)