Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Выполнено плохо. Мутабельная переменная и цикл вместо рекурсии
- object Run {
- def run(body: => Unit) = new {
- def until(condition: Unit => Boolean): Unit = {
- var value = body
- while (!condition(value)) {
- value = body
- }
- value
- }
- }
- def main(args: Array[String]): Unit = {
- val value = run {
- Random.nextInt(10)
- } until (_ == 0)
- println(value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement