Libraryless. Click here for Pure Java version (10148L/56K).
1 | static ItIt<Int> countIterator_inclusive_step(int a, int b, int step) {
|
2 | assertTrue("step > 0", step > 0);
|
3 | |
4 | ret new ItIt<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<Long> countIterator_inclusive_step(long a, long b, long step) {
|
13 | assertTrue("step > 0", step > 0);
|
14 | |
15 | ret new ItIt<Long>() {
|
16 | long i = a; |
17 | |
18 | public bool hasNext() { ret i <= b; }
|
19 | public Long next() { var j = i; i += step; ret j; }
|
20 | }; |
21 | } |
22 | |
23 | static ItIt<Double> countIterator_inclusive_step(double a, double b, double step) {
|
24 | assertTrue("step > 0", step > 0);
|
25 | |
26 | ret new ItIt<Double>() {
|
27 | double i = a; |
28 | |
29 | public bool hasNext() { ret i <= b; }
|
30 | public Double next() { var j = i; i += step; ret j; }
|
31 | }; |
32 | } |
33 | |
34 | static <A> ItIt<A> countIterator_inclusive_step(double a, double b, double step, IF1<Double, A> f) {
|
35 | ret mapI_if1(f, countIterator_inclusive_step(a, b, step)); |
36 | } |
37 | |
38 | static <A> ItIt<A> countIterator_inclusive_step(int a, int b, int step, IF1<Int, A> f) {
|
39 | ret mapI_if1(f, countIterator_inclusive_step(a, b, step)); |
40 | } |
Began life as a copy of #1018110
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
| Snippet ID: | #1032180 |
| Snippet name: | countIterator_inclusive_step - count from a to b (inclusively) with step size |
| Eternal ID of this version: | #1032180/6 |
| Text MD5: | 3bb0152b42ac5cf1396306114d48f841 |
| Transpilation MD5: | 7ac5e17297b6da6ab2dfbdb37bf37dff |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2023-01-21 20:33:13 |
| Source code size: | 1165 bytes / 40 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 425 / 550 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |