6 ms·
What about functions of type A x B -> A ? An example would be C++ stream << operator which takes a stream on the left, a string on the right, and returns a str
by iman 17y ago
What about functions of type A x B -> A ?
An example would be C++ stream << operator which takes a stream on the left, a string on the right, and returns a stream (after writing the string into the stream). This is so that you can do chaining:
cout << "Hello" << "World";
I don't think that there are any mathematical operators that work this way though.
- _delirium 17y agoOne of the comments on the post (by Mathnerd314) says that Icon implements its comparison operators that way (if the comparison succeeds, it returns the 2nd argument).
- miloshh 17y agoIt seems like, to have associativity in the sense of "(a+b)+c = a+(b+c)", you'd have to extend << to also become the string concatenation operator in C++. There are quite a few rules that need to hold to make it work...