Skip to content

osovv/calculator-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby arithmetic calculator

A basic arithmetic calculator implemented in Ruby

Consists of:

  • Lexer (converts input string to array of tokens)
  • Parser (converts array of tokens to RPN)
  • Evaluator (evaluates RPN expression)

Supports following arithmetic operations:

  • + (addition)
  • - (subtraction)
  • / (division)
  • * (multiplication)
  • ^ (exponentiation)
  • log (taking the logarithm)

Usage:

ruby app.rb [expression]

Example:

ruby app.rb "log 100 10 * ((4 - 7) ^ (3 + 1) / 4)"

Releases

No releases published

Packages

No packages published

Languages