Iterator.k 324 B

12345678910111213141516
  1. promise {
  2. function delayed_sequence (n: Int) -> AsyncIterator {
  3. return async iterator {
  4. for i in seq(n) {
  5. await postpone(25)
  6. yield i
  7. }
  8. }
  9. }
  10. var sum = 0
  11. await x in delayed_sequence(5) {
  12. reset sum += x
  13. }
  14. assert sum == 10
  15. }