Re: Discuss changing the behaviour of append()
- Posted by jimcbrown (admin) Jun 22, 2014
- 3992 views
From the Haskell wikibook:
This property is called associativity, and it doesn't hold for only those selected values but for all integers under addition, all integers under multiplication, and all lists under concatenation.
[] is the identity when appending two lists.
Lists form a monoid under concatenation: ([a], (++), [])
Other than one lapse, the term concatenation is used consistently.
Our append ... has no identity.
Agreed.
Our append is strange this way. It has no identity.
Well, I think this is not so strange. Lots of functions lack an identity. f(x) = x + 1 lacks an identity. Logical NOT lacks an identity.
Furthermore, this has nothing to do with the proposed change. Even without it, append lacks an identity. To demonstrate this with the most likely canidate, append({}, {}) does not return {}.
append also lacks associativity. append(1, {}) and append({}, 1) return different things. Again, this is nothing to do with the proposed change - append({1}, {2}) and append({2}, {1}) also return different things. Other mathematical functions, like division or subtraction, also lack associativity.

