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).

1  
static IterableIterator<Int> countIterator_exclusive_step(final int a, final int b, final int step) {
2  
  assertTrue("step > 0", step > 0);
3  
  
4  
  ret new IterableIterator<Int>() {
5  
    int i = a;
6  
    
7  
    public bool hasNext() { ret i < b; }
8  
    public Int next() { var j = i; i += step; ret j; }
9  
  };
10  
}
11  
12  
static ItIt<Double> countIterator_exclusive_step(double a, double b, double step) {
13  
  assertTrue("step > 0", step > 0);
14  
  
15  
  ret new IterableIterator<Double>() {
16  
    double i = a;
17  
    
18  
    public bool hasNext() { ret i < b; }
19  
    public Double next() { var j = i; i += step; ret j; }
20  
  };
21  
}
22  
23  
static <A> ItIt<A> countIterator_exclusive_step(double a, double b, double step, IF1<Double, A> f) {
24  
  ret mapI_if1(f, countIterator_exclusive_step(a, b, step));
25  
}

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: 369 / 432
Version history: 5 change(s)
Referenced in: [show references]