Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 23 days 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 (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-22T15:56:38.000Z (almost 2 years ago)
- Last Synced: 2024-06-19T05:44:30.974Z (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
[![test](https://github.com/lesomnus/boolal/actions/workflows/test.yaml/badge.svg)](https://github.com/lesomnus/boolal/actions/workflows/test.yaml)
[![Go Report Card](https://goreportcard.com/badge/github.com/lesomnus/boolal)](https://goreportcard.com/report/github.com/lesomnus/boolal)
[![codecov](https://codecov.io/gh/lesomnus/boolal/branch/main/graph/badge.svg?token=9JMg9rhj2w)](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
}
```