[Haskell-cafe] adding the elements of two lists

Jerzy Karczmarczuk jerzy.karczmarczuk at unicaen.fr
Mon Mar 26 18:18:41 CEST 2012


Le 26/03/2012 16:31, Chris Smith a écrit :
> If you were
> asking about why there is no ring on [a] that defines (+) = zipWith
> (+), then here's why.  By that definition, you have [1,2,3] + [4,5] =
> [5,7].  But also [1,2,42] + [4,5] = [5,7].  Addition by [4,5] is not
> one-to-one, so [4,5] cannot be invertible.
So, * the addition* is not invertible, why did you introduce rings to 
this discussion, if the additive group within is already lousy?...
OK I see now. You are only interested in the explicitly ambiguous usage 
of the element-wise addition which terminates at the shortest term...
But I don't care about using (+) = zipWith (+) "anywhere", outside of a 
programming model / framework, where you keep the sanity of your data. 
In my programs I KNEW that the length of the list is either fixed, or of 
some minimal size (or infinite). Your [4,5] simply does not belong to MY 
rings, if I decided to keep the other one.

Jerzy K.




More information about the Haskell-Cafe mailing list