Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

39
LINES

< > BotCompany Repo | #1004235 // Java Coroutines Test! [WORKS]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (2389L/15K/56K).

!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!");
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

-
Snippet ID: #1004235
Snippet name: Java Coroutines Test! [WORKS]
Eternal ID of this version: #1004235/2
Text MD5: f8398db82b8a6e68affa160d99571760
Transpilation MD5: ad44aa32e1d05bc9aef9f18b27f1b625
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-14 12:39:53
Source code size: 702 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 1526 / 1327
Version history: 1 change(s)
Referenced in: