/calculadora-react

A simple React calculator, to serve as an starting point for anyone who wants to see how to write tests for his own React applications.

Primary LanguageTypeScriptOtherNOASSERTION

React Calculator

A simple calculator built with React.

Check the calculator working in the browser.

Usage

You can use your keyboard to interact with the calculator:

  • Use C, ESC or Delete to clear the display;
  • Use number keys, parenthesis and . to input data.

The solution

The starting point for this calculator was a workshop of programming languages hosted by Luciano Ramalho at Garoa Hacker Clube (way far from my last attempt). After watching the presentation, I've tried, unsucessfully, to read John McCarthy's paper on which this algorithm is based on (if you want to dive in, this article by Paul Graham is a more accessible introduction to McCarthy's work).

After implementing the evaluate function, I've implemented tokenizer, operators and an infix-to-prefix function (I'm not happy with this last one, therefore, it must change in the future). For the rest, is a React application started with CRA.

TODO

  • Use or to go backwards in the input history;
  • Use or to go forward in the input history;

Contribution

Feel free to contribute with the solution and give me tips and counseling to make it better :)

Author

Douglas Moura

License

This project is licensed under the MIT License - see the LICENSE.md file for details