Calculates the result of a basic math equation stored in a String.
NaiveMather.calculate("3 + 4 * (3 + 4)")
=> 31
Only handles +, -, *, /, and parentheses.
- Add the dependency to your
shard.yml
:
dependencies:
naive_mather:
github: blazerw/naive_mather
- Run
shards install
require "naive_mather"
Just pass your equation String to NaiveMather.calculate()
Follow Crystal's guidelines: https://crystal-lang.org/reference/guides/writing_shards.html and realize that Spec2 is used for testing, specifically this fork
- 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
- Randy Wilson - creator and maintainer
- Lukasz Wrobel - Ruby version, the "real" creator