Evaluates calculations
The syntax is like regular javascript with the exponent ('**') be '^' instead
Original text: '1+(2-1)'
Parsed text (Tape):
[
1,
"+",
[
2,
"-",
1
]
]
Tape (parsed text):
[
1,
"+",
[
2,
"-",
1
]
]
Result: 2
You can use this by importing the script or running it with node (ts) like this:
$ ts-node calculation.ts '1+(2-1)'
[ 1, '+', [ 2, '-', 1 ] ]
2