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

32
LINES

< > BotCompany Repo | #1032842 // Stages

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (9256L/51K).

// goes well with the stage {} macro (see tok_stages)
srecord Stages(new L</*Stage*/Runnable> stages) is Steppable, Runnable {
  replace Stage with Runnable.
  int iStage;
  Stage stage;
  
  public bool step() {
    // What is this funny syntax
    ret iStage <= l(stages)
      && trueBecause(callF(stage = _get(stages, iStage++)));
  }
  
  Stage stage(Stage stage) {
    stages.add(stage);
    ret stage;
  }
  
  Stage stage(S name, Stage stage) {
    ret stage(runnableWithCustomToString(name, stage));
  }
  
  run { stepAll(this); }
  
  int indexOfStage(Stage stage) {
    ret stages.indexOf(stage);
  }
  
  void stepUntilStage(Stage stage) {
    int index = indexOfStage(stage);
    while (iStage <= index && step()) {}
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1032842
Snippet name: Stages
Eternal ID of this version: #1032842/10
Text MD5: f01ccff7d838023d297953e45d2a3f35
Transpilation MD5: 201c8738c9262e2dea14f89a2746fd73
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-06 18:40:03
Source code size: 767 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 163 / 319
Version history: 9 change(s)
Referenced in: [show references]