A binding to libqalculate for lua
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
1.1 KiB

2 years ago
2 years ago
2 years ago
2 years ago
  1. # luaqalculator
  2. This library implmenets some glue between libqalculate and lua, which is used for my bot's calculate function.
  3. Calling this library a "binding" would probably be a mistake seeing that it simply isn't a binding, but rather a thin library that allows calling the "CalculateAndPrint" function from lua.
  4. That being said, it's more than enough for my particular use case.
  5. # Building
  6. To make everything to compile with as few steps as possible you will need `make`, `g++`, `libqalculate` and `lua5.1` (which is the default target).
  7. Once you have all of the above, simply type `make` and it will produce the needed `libqalcaulator.so` library.
  8. If you wish to compile against a different version, simply change the variable `LUA_VERSION` in the makefile to the one you need.
  9. # Usage
  10. ```lua
  11. qalc = require("libqalculator")
  12. print(qalc.qalc("sin(3 rad)")) -- Approximate mode (will return an interval with approximate values)
  13. print(qalc.qalc("sin(3 rad)", true)) -- Exact mode (will return "sin(3 rad)" to avoid approximation)
  14. ```
  15. # License
  16. This project is licensed under the MIT license (located in the `LICENSE` file)