Skip to content

Commit

Permalink
Using some lib for bigints
Browse files Browse the repository at this point in the history
  • Loading branch information
belyaev-mikhail committed Aug 21, 2020
1 parent 4f92096 commit ba36629
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>1.3.72</kotlin.version>
<kotlin.version>1.4.0</kotlin.version>
<kotlin.code.style>official</kotlin.code.style>
<junit.version>4.12</junit.version>
</properties>
Expand All @@ -39,6 +39,11 @@
<artifactId>kotlinx-collections-immutable-jvm</artifactId>
<version>0.3.2</version>
</dependency>
<dependency>
<groupId>com.ionspin.kotlin</groupId>
<artifactId>bignum-jvm</artifactId>
<version>0.2.0</version>
</dependency>
</dependencies>

<build>
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/ru/spbstu/logic/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ fun main(args: Array<String>) {
var b by vars
var c by vars
var d by vars
eqlO(a, b)
a = nat(30)
mulO(a, b, c)
//x = nat(3)

}
Expand Down
6 changes: 5 additions & 1 deletion src/main/kotlin/ru/spbstu/logic/lib/Reify.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package ru.spbstu.logic.lib

import com.ionspin.kotlin.bignum.integer.BigInteger
import com.ionspin.kotlin.bignum.integer.*
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.plus
import ru.spbstu.logic.App
import ru.spbstu.logic.Constant
import ru.spbstu.logic.Expr
import java.math.BigInteger
import ru.spbstu.wheels.tryEx

fun String.toBigIntegerOrNull(): BigInteger? = tryEx { toBigInteger() }.getOrNull()

fun reifyAsNumber(expr: Expr): BigInteger? = run {
when (expr) {
Expand Down

0 comments on commit ba36629

Please sign in to comment.