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>>(
1515 override val endInclusive: I = last
1616
1717 override val endExclusive: I by lazy {
18- check(endInclusive == start .maxValue) {
18+ check(endInclusive != endInclusive .maxValue) {
1919 " Cannot return the exclusive upper bound of a range that includes MAX_VALUE."
2020 }
2121 endInclusive + endInclusive.one
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ value class UOctal internal constructor(
4040 override fun compareTo (other : UOctal ): Int =
4141 data.compareTo(other.data)
4242
43- operator fun rangeTo (other : UOctal ): OpenEndRange <UOctal > =
43+ operator fun rangeTo (other : UOctal ): ClosedRange <UOctal > =
4444 IntegralRange (this , other)
4545
4646 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> {
1212 val ZERO : SignedIntegral = SignedIntegral (0 )
1313
1414 val ONE : SignedIntegral = SignedIntegral (1 )
15+
16+ val NEGATIVE_ONE : SignedIntegral = SignedIntegral (- 1 )
1517 }
1618
1719 override val minValue: SignedIntegral
@@ -46,4 +48,9 @@ value class SignedIntegral(private val i: Int) : Integral<SignedIntegral> {
4648
4749 operator fun rangeUntil (other : SignedIntegral ): OpenEndRange <SignedIntegral > =
4850 IntegralRange (this , other - ONE )
51+
52+ override fun toString (): String = i.toString()
4953}
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