Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brentp/kexpr-nim
nim wrapper for Heng Li's kexpr math expression evaluator library
https://github.com/brentp/kexpr-nim
evaluator math math-expressions nim-lang
Last synced: 3 months ago
JSON representation
nim wrapper for Heng Li's kexpr math expression evaluator library
- Host: GitHub
- URL: https://github.com/brentp/kexpr-nim
- Owner: brentp
- License: other
- Created: 2017-10-04T21:08:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-11-06T15:02:15.000Z (about 4 years ago)
- Last Synced: 2024-09-20T00:04:37.106Z (4 months ago)
- Topics: evaluator, math, math-expressions, nim-lang
- Language: C
- Homepage:
- Size: 29.3 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kexpr-nim
nim wrapper for Heng Li's kexpr math expression library[![badge](https://img.shields.io/badge/docs-latest-blue.svg)](https://brentp.github.io/kexpr-nim/)
```Nim
var e = expression("5*6+x > 20")
e["x"] = 10
echo e.int
e["x"] = 20
echo e.int64
assert e.error() == 0e = expression("(sample1 > 20 & sample2 > 10 & sample3 < 40")
# missing paren
assert e.error() != 0
e.clear()e = expression("(sample1 > 20) & (sample2 > 10) & (sample3 < 40)")
e["sample1"] = 21; e["sample2"] = 65; e["sample3"] = 20
echo e.int # 1
e["sample1"] = 0
echo e.int # 0
assert e.error() == 0
echo e.float # 0.0
```## installation
If you have nimble installed you can do:
```
nimble install kexpr
```[![nimble](https://raw.githubusercontent.com/yglukhov/nimble-tag/master/nimble.png)](https://github.com/nim-lang/nimble)