github.com/fatlotus/mast (go): Because Go does not support operator overloading, most numerical libraries are messy to use. M-AST is an attempt to write a domain-specific language for math, so that code can be written in a more simple way.  If it helps, think regular expressions, but for algebra.  Mast mostly exists to create parsers for math-like languages. To use it, first create a *mast.Parser object, configuring the various operations and their precidence.  Then you invoke the (p *mast.Parser).Parse(string) (*mast.Equation, error) function.  Suppose we want to make a basic calculator parser. First, define which operations and grouping operators we want to support:  To parse a string using this language, invoke (p *mast.Parser) Parse(string) (*mast.Equation, error) with the source code to evaluate. For example, if we run:  then err will be nil and tree will be as follows:  By iterating over the tree, your DSL can evaluate the mathematical expression while maintaining type integrity.  Mast includes a toy evaluator that handles matrices as [][]float64. To use it, invoke the Eval(code string, args ...interface{}) error function, passing pointers to the respective arguments.  Think %-arguments to fmt.Printf. To make setting up variables easier, arguments can be specified in three ways:  All other types panic.  Suppose we want to compute a linear transform (multiplying a vector by a matrix, and adding a vector). First, we set up the variables to compute:  Once those are set up, the computation is fairly easy.  The result is then available in y.
Keywords: language|math|parse