progs/lecture3.scala
changeset 170 37b1bfcdba79
parent 158 94b11ac19b41
child 178 fdf77ee57cdc
--- 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`