https://github.com/lesomnus/boolal
Evaluate a boolean expression
https://github.com/lesomnus/boolal
bool bool-expression boolean boolean-algebra boolean-expression boolean-expression-parser
Last synced: 4 months ago
JSON representation
Evaluate a boolean expression
- Host: GitHub
- URL: https://github.com/lesomnus/boolal
- Owner: lesomnus
- License: apache-2.0
- Created: 2022-11-10T17:23:19.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-22T15:56:38.000Z (over 2 years ago)
- Last Synced: 2025-01-27T23:36:06.756Z (6 months ago)
- Topics: bool, bool-expression, boolean, boolean-algebra, boolean-expression, boolean-expression-parser
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# *bool*ean *al*gebra
[](https://github.com/lesomnus/boolal/actions/workflows/test.yaml)
[](https://goreportcard.com/report/github.com/lesomnus/boolal)
[](https://codecov.io/gh/lesomnus/boolal)Evaluate a boolean expression.
## Usage
```go
import ba "github.com/lesomnus/boolal"func Expression() {
data := map[string]bool{"t": true}
expr, err := ba.ParseString("t & f | !(t | f)")
if err != nil {
panic(err)
}ok := expr.Eval(data)
// ok == false
}func Manipulation() {
data := map[string]bool{"t": true}
expr := ba.And("t", "f").Or(ba.Not(ba.Or("t", "f")))ok := expr.Eval(data)
// ok == false
}
```