I am using Scala and reading input from the console. I am able to regurgitate the strings that make up each line, but if my input has the following format, how can I access each integer within each line?
2 2 1 2 2 2 1 1 Currently I just regurgitate the input back to the console using
object Main { def main(args: Array[String]): Unit = { for (ln <- io.Source.stdin.getLines) println(ln) //how can I access each individual number within each line? } } And I need to compile this project like so:
$ scalac main.scala
$ scala Main <input01.txt 2 2 1 2 2 2 1 1