Nice solution to the problem, but you can simplify. Addition is associative, e.g.
a+(b+c) = (a+b)+c = a+b+c
(Subtraction is trivially changed to addition 2 - 1 = 2 + -1. I see you have understood this).
As the parenthesis don't do anything, you can just ignore them. (I would set up a range a characters to ignore, and add whitespace to it as well)
I've got to go to a meeting now, but I'll post an F# version later - might be able to get it down to a single expression.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice solution to the problem, but you can simplify. Addition is associative, e.g.
a+(b+c) = (a+b)+c = a+b+c
(Subtraction is trivially changed to addition 2 - 1 = 2 + -1. I see you have understood this).
As the parenthesis don't do anything, you can just ignore them. (I would set up a range a characters to ignore, and add whitespace to it as well)
I've got to go to a meeting now, but I'll post an F# version later - might be able to get it down to a single expression.