3 ms·
> Functions Are Asymmetric No, bijective functions are symmetric. Injectivity is enough to invert a function. > Even though they may take any number of argum
by sshine 1y ago
> Functions Are Asymmetric
No, bijective functions are symmetric.
Injectivity is enough to invert a function.
> Even though they may take any number of arguments, they must each have one return value. [...] This is true of all functions.
Mathematical functions take one value and produce one value. This is true of all mathematical functions.
Programming functions can be modelled this way by treating multiple input arguments as a single product, and non-scalar outputs containing multiple values as a single product.
Programming functions don't even have to always return one value:
- Haskell's Void type
- Rust's ! type
- TypeScript's never type
all have zero values, meaning the function can't meaningfully return.
Arguably, programming functions must take at least one value as input, otherwise how can they be called?
In that sense, programming functions are asymmetric: It rarely makes sense to write a function you can't call, but it often makes sense to write a function that never returns.
When does it make sense to write a function that you can't call? When the point of the function is to prove something as a result of being compiled. The value lies in the compilation, not in being called.
A better title for this article: Some Functions Are Asymmetric.
Which is less of a profound insight.
- Nevermark 1y ago> A better title for this article: Some Functions Are Asymmetric. If some functions are asymmetric, then functions (as a class of things) are not symmetric. Just as some rectangles are squares, still leaves rectangle as a class/type as transpose asymmetric. I.e. width and height are not constrained to be equivalent, which is required for transpose symmetry. Not really arguing for or against your comment. Just noting that it’s easy for multiple valid arguments to pass each other without connecting due to slight differences in what people mean with the same words.