Code Monkey home page Code Monkey logo

jalgebra's Introduction

algebra_ws

A webservice to solve algebraic expressions

JSON format

Specification:

  • Each operation is a JSON object (let's call it AlgebraNode from now on) composed of up to 4 parameters: type (enum), name (enum), op1 (AlgebraValue), op2 (AlgebraValue).
  • Operands op1 and op2 are represented using a JSON object (AlgebraValue) composed by a 2 required parameters: value and literal.
    • value parameter in AlgebraValue is an integer or string
    • the literal part is an array of JSON objects (LiteralPart).
      • LiteralPart object has two required parameters: value (string) and exponent (integer).
  • An AlgebraNode type can be one of the following strings: "plus", "minus", "multiply", "divide" or "function" (case insensitive).
    • If type is different than "function" then both op1 and op2 are required and must be either an AlgebraNode or ValueNode object. Otherwise, depending on the function, only op1 or both op1 and op2 are required.
    • When AlgebraNode type is "function" an optional "name" parameter is required. At this point, the name parameter can either be "abs" or "sizeof".
    • sizeOf() function can work only on one operand that is an AlgebraValue with a string type value.
    • abs() function can work only on one operand that is an AlgebraValue with an integer type value (literals are allowed).

Example

  • (2*2a^2) + sizeof("hello")
{
    "type": "plus",
    "op1": {
        "type": "multiply",
        "op1": {
            "type": "plus",
            "op1": {
                "value": "2",
                "literal": []
            },
            "op2": {
                "value": "2",
                "literal": [
                    {
                        "value": "a",
                        "exponent": 2
                    }
                ]
            }
        }
    },
    "op2": {
        "type": "function",
        "name": "sizeof",
        "op1": {
            "value": "hello",
            "literal": []
        }
    }
}

More examples can be found here

Build and deploy

In order to build and deploy the webservice use the following command: gradlew -PhttpPort=8888 appRunWar

The appRunWar task will take care compiling a war file and deploying in a Tomcat9 instance accessible from http://localhost:PORT

If you are only interested in building a war file use the command: gradlew war. The output war can be found in the build/libs folder.

How to use

  1. Send a post request following the proposed specification at http://localhost:PORT/algebra/solver. The body of the request must contain the JSON object representing the algebraic exprassion you wish to solve.
  2. Read the response of the server (the body is a JSON object represeting the result of the algebraic expression)

jalgebra's People

Contributors

leosarra avatar lrusso96 avatar

Watchers

James Cloos avatar Axel Kramer avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.