From 7e328a5dbf936256a4612f582b5802b3d8e5a9aa Mon Sep 17 00:00:00 2001 From: Gleb Minaev <43728100+lounres@users.noreply.github.com> Date: Fri, 25 Mar 2022 00:59:48 +0300 Subject: [PATCH] Enhanced DSL constructor a bit. --- .../space/kscience/kmath/functions/NumberedPolynomial.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/NumberedPolynomial.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/NumberedPolynomial.kt index 51f316c5d..f931e8e7e 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/NumberedPolynomial.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/NumberedPolynomial.kt @@ -157,7 +157,8 @@ public class NumberedPolynomialTermSignatureBuilder { signature[this] = deg } } - public infix fun Int.to(deg: UInt): Unit = this inPowerOf deg + public infix fun Int.pow(deg: UInt): Unit = this inPowerOf deg + public infix fun Int.of(deg: UInt): Unit = this inPowerOf deg } @NumberedPolynomialConstructorDSL @@ -168,6 +169,7 @@ public class NumberedPolynomialBuilderOverRing internal constructor(internal val signature = NumberedPolynomialTermSignatureBuilder().apply(block).build() coefficients[signature] = context { coefficients.getOrElse(signature) { zero } + this@invoke } } + public infix fun C.with(block: NumberedPolynomialTermSignatureBuilder.() -> Unit): Unit = this.invoke(block) } @NumberedPolynomialConstructorDSL