How to print text diagonally from left to right in Scala

1 Answer

0 votes
object DiagonalHelloWorld extends App {
  val text = "Hello World"

  for ((ch, idx) <- text.zipWithIndex) {
    println(" " * idx + ch)
  }
}


/*
run:
 
H
 e
  l
   l
    o
      
      W
       o
        r
         l
          d
 
*/

 



answered Apr 6 by avibootz
...