!7 !include #1004241 // Coroutines static int i; p { // Prelude tests O b; eval(b = _block( r { print("hello"); }, r { print("world."); })); stepAll(b); assertEquals("a", new If(func { true }, "a", "b").get()); assertEquals("b", new If(func { false }, "a", "b").get()); // This is the actual coroutine. //stepAll_verbose = true; stepAll_steps = 0; stepAll( // Here it goes: _for(r { i = 1 }, func { i <= 3 }, r { ++i }, r { print("Counting to " + i + "!"); } // Done! )); print("Steps: " + stepAll_steps); // How many coroutine steps it took. print("OK!"); }