Is there a way to express the inverse of any function in Scala?
For example if I have a function f
like this:
(x: Int) => x + 1
I am adding an answer because of another question marked as a duplicate of this one, and nobody seems to have mentioned this yet: it is theoretically possible to automatically compute the "inverse" (in the sense that it performs exhaustive search over the input, and answers "none" if there is no solution, within a finite amount of time) of functions over infinite sequences of binary digits: see the article "Seemingly impossible functional programs" (though it uses Haskell, not Scala).
Practical utility of this exhaustive search is another matter, of course.