Skip to content

Formath is a simple parser and evaluator for mathematical expressions

License

Notifications You must be signed in to change notification settings

aspl-lang/formath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Formath

Format + Math = Formath

Formath is a simple parser and evaluator for mathematical expressions. It can be used in tools like calculators, spreadsheets or plotters.

Features

  • Basic arithmetic operations: +, -, *, /, %
  • Trigonometric functions: sin, cos, tan, asin, acos, atan
  • An arbitrary number of nested parentheses: ((1 + 2) * 3)
  • Variables: x, y, z, etc.

Usage

import formath

var context = new Context({"x" => 5d})
print(formath.parse("123", context).evaluate(context)) // 123
print(formath.parse("1 + 2", context).evaluate(context)) // 3
print(formath.parse("1+2 * 3", context).evaluate(context)) // 7
print(formath.parse("((x + 2) * 3)", context).evaluate(context)) // 21

About

Formath is a simple parser and evaluator for mathematical expressions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published