Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lua-exprtk

License

A lua wrapper for exprtk (C++ Mathematical Expression Parsing And Evaluation Library)

Usage

local exprtk = require('lua-exprtk')

local varMap = exprtk.variable_map.new()
varMap:insert('a')

local symbols = exprtk.symbol_table.new()
symbols:add_constants()
symbols:add_variables(varMap)

local expr = exprtk.expression.new()
expr:register_symbol_table(symbols)

local parser = exprtk.parser.new()

local success,err = parser:compile('clamp(-0.5,sin(a*pi/180),0.5)', expr)
if not success then
    print('Error during parsing:', err)
    return
end

for i=0,360 do
    varMap:set('a', i)
    print(i, expr:value())
end

For a full list of expressions, look here.

Remarks

  • lua-exprtk was compiled and tested with macOS 10.14, Windows 10 x64 and Ubuntu 20.04 x64.
  • Compilation takes some time, most probably because of the huge header-only libs sol2 and exprtk.
  • lua-exprtk is also available via LuaRocks.

External dependencies (included)

About

A lua wrapper for exprtk (C++ Mathematical Expression Parsing And Evaluation Library)

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages