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

25
LINES

< > BotCompany Repo | #1018110 // countIterator_exclusive_step - count from a to b (exclusively) with step size

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

Libraryless. Click here for Pure Java version (3074L/17K).

static IterableIterator<Int> countIterator_exclusive_step(final int a, final int b, final int step) {
  assertTrue("step > 0", step > 0);
  
  ret new IterableIterator<Int>() {
    int i = a;
    
    public bool hasNext() { ret i < b; }
    public Int next() { var j = i; i += step; ret j; }
  };
}

static ItIt<Double> countIterator_exclusive_step(double a, double b, double step) {
  assertTrue("step > 0", step > 0);
  
  ret new IterableIterator<Double>() {
    double i = a;
    
    public bool hasNext() { ret i < b; }
    public Double next() { var j = i; i += step; ret j; }
  };
}

static <A> ItIt<A> countIterator_exclusive_step(double a, double b, double step, IF1<Double, A> f) {
  ret mapI_if1(f, countIterator_exclusive_step(a, b, step));
}

Author comment

Began life as a copy of #1018109

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018110
Snippet name: countIterator_exclusive_step - count from a to b (exclusively) with step size
Eternal ID of this version: #1018110/6
Text MD5: 546069d971c7ddbbbe9bd14d002074d7
Transpilation MD5: b5915547cc640361e9561120253a44b5
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-08 14:52:54
Source code size: 782 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 366 / 429
Version history: 5 change(s)
Referenced in: [show references]