Skip to content

itsfergydanny/SExpressionCalculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SExpressionCalculator

I was tasked to create a simple integer calculator that can process a syntax that resembles S-expressions which can take english like expressions and return their result and that is capable of processing nested expressions.


How to compile

Requirements:

  • Java 17
  • Maven

You can compile the project using Maven by running the following while in the project root folder:

mvn package

How to execute

Once compiled, you can run the jar as follows:

java -jar ./target/SExpressionCalculator-1.0-SNAPSHOT-shaded.jar "<expression>"

# For example
java -jar ./target/SExpressionCalculator-1.0-SNAPSHOT-shaded.jar "(add 12 12)"

An expression is formed the following way: (function integer/nested expression integer/nested expression)


Available functions:
Name Syntax Example Expected Result
Add (add 10 10) 20
Multiply (multiply 10 5) 50
Subtract (subtract 100 25) 75
Exponent (exponent 2 5) 32

Extra credit:

  • Implemented subtract and exponent function types since it was easy to extend my base code to cover these.
  • Made it so you can specify as many arguments to a function as you want, for example: "add 10 20 30 40 50"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages