Implementation of Dijkstra's (full parentheses) arithmetic algorithm