They are not contradictory in that the math doesn’t work out. They are contradictory in that it is not possible to write one addSubtract function that returns both of those values. The first example strictly returns a number after 3 iterations, while the second example strictly returns a function after 3 iterations. How can one function do both?

At the very least, the function would need to be arbitrarily stateful instead of extensible, as another commentor provided as an example. This article covers a stateless and extensible implementation of a possible solution.

Senior front end engineer / charlesstover.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store