naive_mather
Calculates the result of a basic math equation stored in a String.
NaiveMather.calculate("3 + 4 * (3 + 4)")
=> 31
Only handles +, -, *, /, and parentheses.
Installation
- Add the dependency to your
shard.yml
:
dependencies:
naive_mather:
github: blazerw/naive_mather
- Run
shards install
Usage
require "naive_mather"
Just pass your equation String to NaiveMather.calculate()
Development
Follow Crystal's guidelines: https://crystal-lang.org/reference/guides/writing_shards.html and realize that Spec2 is used for testing, specifically this fork
Contributing
- Fork it (<https://github.com/blazerw/naive_mather/fork>)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Randy Wilson - creator and maintainer
- Lukasz Wrobel - Ruby version, the "real" creator