// Current imperative looping approach: // for (for-each in some languages): // do something with every element of a collection // (including, known number of times ala sequence) // for (item in collection) { // // code, that typically references item // } // Question: how to loop until a *condition* is met? // Conditional looping: continue while a Boolean expression is true // while (condition) { // // code // } // val num = 7 // while (num % 2 == 1) { // println("$num is odd") // } // Questions: // 1. Similar to something we've seen with recursion? Same? // 2. Why does this feel limiting? // import khoury.input // import khoury.isAnInteger // fun getEvenNum(): Int { // while (true) { // println("Enter an even number") // val typed = input() // if (isAnInteger(typed)) { // val num = typed.toInt() // if (num % 2 == 0) { // return num // } // } // } // } // val myNum = getEvenNum() // println("Even number: $myNum") // do { // // code // } while (condition) import khoury.input do { println("Are we there yet?") val thereYet = input() } while (thereYet != "I give up") println("😈") // Questions: // 1. What's the difference (while vs do-while)? // 2. How do I know when to use for vs while/do-while?