{"id":50396047,"url":"https://github.com/eltony81/easy_expression_eval","last_synced_at":"2026-05-30T21:01:05.982Z","repository":{"id":146125794,"uuid":"571465851","full_name":"eltony81/easy_expression_eval","owner":"eltony81","description":"Math expression evaluator","archived":false,"fork":false,"pushed_at":"2026-05-29T07:06:22.000Z","size":108,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-29T09:08:43.787Z","etag":null,"topics":["crystal","crystal-lang","evaluator","expression","infix-notation","math"],"latest_commit_sha":null,"homepage":"","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eltony81.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-11-28T07:37:27.000Z","updated_at":"2026-05-28T21:41:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"c751ed32-7b1e-41b2-9953-c1c80cf7b4e6","html_url":"https://github.com/eltony81/easy_expression_eval","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/eltony81/easy_expression_eval","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eltony81%2Feasy_expression_eval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eltony81%2Feasy_expression_eval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eltony81%2Feasy_expression_eval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eltony81%2Feasy_expression_eval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eltony81","download_url":"https://codeload.github.com/eltony81/easy_expression_eval/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eltony81%2Feasy_expression_eval/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33709269,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crystal","crystal-lang","evaluator","expression","infix-notation","math"],"created_at":"2026-05-30T21:01:05.165Z","updated_at":"2026-05-30T21:01:05.973Z","avatar_url":"https://github.com/eltony81.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easy Expression Eval (eeeval)\n\n![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/eltony81/easy_expression_eval?display_name=tag)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/eltony81/easy_expression_eval/crystal.yml)\n\n**eeeval** is a lightweight and efficient expression evaluator for Crystal. It supports mathematical calculations, user-defined variables, pre-compiled ASTs for performance, and conditional expressions.\n\n---\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     eeeval:\n       github: eltony81/easy_expression_eval\n   ```\n\n2. Run `shards install`\n\n## Features\n\n### Mathematical Evaluation\n\nYou can evaluate complex mathematical expressions with a single call:\n\n```crystal\nrequire \"eeeval\"\n\n# Simple evaluation\nresult = EEEval::CalcFuncParser.evaluate(\"(14.2 + 14.2) * 4 / 2 * 10.5 ^ (2 / 0.5)\")\nputs result\n```\n\n#### Variables Support\n\nPass a hash of variables to the evaluator:\n\n```crystal\nvars = {\"x\" =\u003e 3.0, \"y\" =\u003e 1.5}\nresult = EEEval::CalcFuncParser.evaluate(\"x^2 + sin(y)\", vars)\nputs result\n```\n\n#### Pre-compilation (AST)\n\nFor performance-critical code (e.g., inside loops), compile the expression into an AST once and reuse it:\n\n```crystal\nast = EEEval::CalcFuncParser.compile(\"sin(x) * phi\")\n\n(0..100).each do |i|\n  res = EEEval::CalcFuncParser.evaluate(ast, {\"x\" =\u003e i.to_f})\n  puts \"f(#{i}) = #{res}\"\nend\n```\n\n### Conditional Expressions\n\nThe library includes a `CondParser` for boolean logic:\n\n```crystal\n# Numeric comparisons\nEEEval::CondParser.evaluate(\"10 == 10\")    # =\u003e true\nEEEval::CondParser.evaluate(\"5 != 3\")      # =\u003e true\n\n# String comparisons\nEEEval::CondParser.evaluate(\"'hello' == 'hello'\") # =\u003e true\n\n# Logical operators\nEEEval::CondParser.evaluate(\"(1 == 1) \u0026\u0026 (2 != 3)\") # =\u003e true\nEEEval::CondParser.evaluate(\"1 == 0 || 1 == 1\")     # =\u003e true\n```\n\n### Built-in Support\n\n- **Constants**: `pi`, `e`, `tau`, `sqrt2`, `phi`, `rad2deg`, `deg2rad`, `g`, `inf`, `nan`.\n- **Functions**: `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `sinh`, `cosh`, `tanh`, `log`, `log2`, `log10`, `exp`, `exp2`, `sqrt`, `abs`, `floor`, `ceil`, `round`, `sgn`, `gamma`.\n- **Operators**: `+`, `-`, `*`, `/`, `^` (power), `%` (modulo).\n\n---\n\n## CLI Usage\n\nThe library includes a CLI tool for quick evaluations and range calculations.\n\n### Parameters:\n- `-v, --var VAR`: Specify the variable name to use in the expression (e.g., `x`, `t`).\n- `-s, --start VAL`: Set the starting value for the range evaluation.\n- `-e, --end VAL`: Set the ending value for the range evaluation.\n- `-d, --step VAL`: Set the increment step size (defaults to `1.0`).\n\n### Examples:\n\n**Single expression evaluation:**\n```bash\ncrystal run src/cli.cr -- \"sin(pi/2) + e\"\n```\n\n**Range evaluation (vector calculation):**\nThis will evaluate the expression for `x` from `0` to `10` with a step of `0.5`, producing a vector of results.\n```bash\ncrystal run src/cli.cr -- -v x -s 0 -e 10 -d 0.5 \"x^2 + sin(x)\"\n```\n\n---\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/eltony81/easy_expression_eval/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [eltony81](https://github.com/eltony81) - creator and maintainer\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feltony81%2Feasy_expression_eval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feltony81%2Feasy_expression_eval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feltony81%2Feasy_expression_eval/lists"}