Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. def execute[A](ui: UserInteraction[A]): A = ui match {
  2. case Tell(statement) =>
  3. println(statement)
  4. statement
  5. case Ask(question) =>
  6. println(question)
  7. val answer = scala.io.StdIn.readLine()
  8. answer.asInstanceOf[A] // to make compiler happy
  9. }
  10.  
  11. def run[A](program: List[UserInteraction[A]]): Unit = program.foreach(execute)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement