diff -r 8a1bd8ddb96c -r 3d760b06befa progs/lecture3.scala --- a/progs/lecture3.scala Fri Jan 19 14:09:08 2018 +0000 +++ b/progs/lecture3.scala Fri Feb 23 22:26:42 2018 +0000 @@ -509,3 +509,20 @@ // I like best about Scala that it lets me often write // concise, readable code. + + +// You can define your own while loop + + +def my_while(condition: => Boolean)(block: => Unit): Unit = + if (condition) { block ; my_while(condition) { block } } else { } + + +var x = 10 +my_while (x > 0) { + println(s"$x") ; x = x - 1 +} + + +`symbol +`symbol`