Multiplatform library witch can make the expression easier. This library can be used on JVM, JS, Swift.
You can use exist classes in org.expressions.impl for create condition and SimplerBooleanExpression for doing simple your condition.
For example with using constructor:
import org.expressions.SimplerBooleanExpression
import org.expressions.impl.*
// A && (B || A) -> A
fun main() {
// Define condition "A && (B || A)"
val condition = AndCondition(
Condition("A"),
OrCondition(
Condition("B"),
Condition("A"),
)
)
println(condition.toString()) // (A && (B || A))
// Create instance SimplerBooleanExpression
val simpler = SimplerBooleanExpression()
// Make easier
val simpled = simpler.simplify(condition)
println(simpled.toString()) // A
}
For example with using methods:
import org.expressions.SimplerBooleanExpression
import org.expressions.impl.*
// A && (B || A) -> A
fun main() {
// Define condition "A && (B || A)"
val condition = Condition("A").and(Condition("B").or(Condition("A")))
println(condition.toString()) // (A && (B || A))
// Create instance SimplerBooleanExpression
val simpler = SimplerBooleanExpression()
// Make easier
val simpled = simpler.simplify(condition)
println(simpled.toString()) // A
}
If you want to use custom conditions, you need implement interface SimplifiedCondition, and then you could use SimplerBooleanExpression similarly first code examples.
Run bash
./gradlew jvmJar
Then go to build/libs
for take *.jar
You can run website and try parse boolean expressions fom string and see result optimization.
If you want it, you should run this bash command.
./gradlew jsBrowserDistribution
And after that open index.html from build/distributions/
.
// TODO add implements with using array
// TODO add implements with using macOS
Run tests and generate coverage.
./gradlew koverReport
Watch coverage go to build/reports/kover/html/index.html
Watch now https://tihon-ustinov.github.io/boolean-expression-siplify/
If you want HTML documentation
./gradlew dokkaHtml
Then go to build/dokka/html/index.html
If you want Markdown documentation
./gradlew dokkaGfm
Then go to build/dokka/gfm/index.md
- Add implements with using array
- Add implements with using macOS
- Publish to maven central and npm
- Make html with parse string condition and make it easier