Please find calculator.asl.json
, an Amazon states language definition that can Add, Subtract, Divide and multiply two whole numbers together.
This was a thought-provoking exercise not intended to be used for workloads, but to demonstrate how you can achieve basic math operations by combining intrinsic functions.
To use, please see Getting started with AWS Step Functions and update the ASL. No Additional IAM permissions are required.
Please see the StepFunction graph below:
This StepFunction inputs 2 whole numbers (X and Y) and an operation (+-*÷).
The result is: X operation Y
Input:
{
"x": 5,
"y": 25,
"operation": "+"
}
Output:
{
"result": 30
}
Input:
{
"x": 50,
"y": 8,
"operation": "-"
}
Output:
{
"result": 42
}
Input:
{
"x": 6,
"y": 4,
"operation": "*"
}
Output:
{
"result": 24
}
Input:
{
"x": 70,
"y": 10,
"operation": "÷"
}
Output:
{
"result": 7
}
Note: When the result is not a whole number it will always round up. e.g. 10 ÷ 4 = 3
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.