(long start, long end, long step)
| 47 | |
| 48 | // returns exact size of remaining items OR throws ArithmeticException for overflow case |
| 49 | static long rangeCount(long start, long end, long step) { |
| 50 | // (1) count = ceiling ( (end - start) / step ) |
| 51 | // (2) ceiling(a/b) = (a+b+o)/b where o=-1 for positive stepping and +1 for negative stepping |
| 52 | // thus: count = end - start + step + o / step |
| 53 | return Numbers.add(Numbers.add(Numbers.minus(end, start), step), step > 0 ? -1 : 1) / step; |
| 54 | } |
| 55 | |
| 56 | public static ISeq create(long end) { |
| 57 | if(end > 0) { |