Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 10th, 2013  |  syntax: Scala  |  size: 0.62 KB  |  hits: 53  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. object MainObject {
  2.  
  3.   def main(args: Array[String]): Unit = {
  4.     println("Please write a number and number lines")
  5.     val inputLines = readInt
  6.     var lines : List[String] = List()
  7.     for(i <- 0 until inputLines){
  8.         lines = lines :+ readLine().toString()
  9.     }
  10.    
  11.     val chars = lines.map( _.toList ).toSeq
  12.     consume(chars)
  13.      
  14.    
  15.   }
  16.  
  17.   def consume(lines: Seq[List[Char]]) : Unit = {
  18.      lines.foreach(
  19.                 l =>
  20.                         print(l.headOption.map( _.toString ).getOrElse(" "))
  21.      )
  22.      println()
  23.      if (lines.filter( _.length > 0 ).nonEmpty) consume( lines.map( _.drop(1) ) )
  24.   }
  25.  
  26. }