File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed
subprojects/user-defined-integrals-in-kotlin/src
main/kotlin/org/sdkotlin/integral
test/kotlin/org/sdkotlin/integral Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ class IntegralRange<I : Integral<I>>(
15
15
override val endInclusive: I = last
16
16
17
17
override val endExclusive: I by lazy {
18
- check(endInclusive == start .maxValue) {
18
+ check(endInclusive != endInclusive .maxValue) {
19
19
" Cannot return the exclusive upper bound of a range that includes MAX_VALUE."
20
20
}
21
21
endInclusive + endInclusive.one
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ value class UOctal internal constructor(
40
40
override fun compareTo (other : UOctal ): Int =
41
41
data.compareTo(other.data)
42
42
43
- operator fun rangeTo (other : UOctal ): OpenEndRange <UOctal > =
43
+ operator fun rangeTo (other : UOctal ): ClosedRange <UOctal > =
44
44
IntegralRange (this , other)
45
45
46
46
operator fun rangeUntil (other : UOctal ): OpenEndRange <UOctal > =
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ value class SignedIntegral(private val i: Int) : Integral<SignedIntegral> {
12
12
val ZERO : SignedIntegral = SignedIntegral (0 )
13
13
14
14
val ONE : SignedIntegral = SignedIntegral (1 )
15
+
16
+ val NEGATIVE_ONE : SignedIntegral = SignedIntegral (- 1 )
15
17
}
16
18
17
19
override val minValue: SignedIntegral
@@ -46,4 +48,9 @@ value class SignedIntegral(private val i: Int) : Integral<SignedIntegral> {
46
48
47
49
operator fun rangeUntil (other : SignedIntegral ): OpenEndRange <SignedIntegral > =
48
50
IntegralRange (this , other - ONE )
51
+
52
+ override fun toString (): String = i.toString()
49
53
}
54
+
55
+ infix fun SignedIntegral.downTo (to : SignedIntegral ): IntegralProgression <SignedIntegral > =
56
+ IntegralProgression .fromClosedRange(this , to, SignedIntegral .NEGATIVE_ONE )
You can’t perform that action at this time.
0 commit comments