Advertisement
Guest User

1

a guest
Jul 20th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.32 KB | None | 0 0
  1. object WhileLoop {
  2.  
  3.   @tailrec
  4.   def whileLoop(b: => Boolean, command: => Unit): Unit  = {
  5.     if (b) {
  6.       (command);
  7.       whileLoop(b, command)
  8.     } else ()
  9.   }
  10.  
  11.   def main(args: Array[String]): Unit = {
  12.     val mas = Array(1, 2, 3)
  13.     var i = 0
  14.     whileLoop(i < mas.length, { println(i); i += 1 })
  15.   }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement