News for hackers. Stuff that matters.
Re:Many programming languages have infix expressions, but ge... by iman on Monday February 01, 2010 @05:41AM (#1092152)
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.
Re:Many programming languages have infix expressions, but ge... by miloshh on Monday February 01, 2010 @08:54AM (#1092322)
It 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...
Re:Many programming languages have infix expressions, but ge... by _delirium on Monday February 01, 2010 @06:05AM (#1092165)
One 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).