sum works in sequences (Python 3)
Terry Reedy
tjreedy at udel.edu
Wed Sep 19 14:49:45 EDT 2012
On 9/19/2012 11:07 AM, Alister wrote:
> Summation is a mathematical function that works on numbers
> Concatenation is the process of appending 1 string to another
>
> although they are not related to each other they do share the same
> operator(+) which is the cause of confusion.
If one represents counts in unary, as a sequence or tally of 1s (or
other markers indicating 'successor' or 'increment'), then count
addition is sequence concatenation. I think Guido got it right.
It happens that when the members of all sequences are identical, there
is a much more compact exponential place value notation that enables
more efficient addition and other operations. When not, other tricks are
needed to avoid so much copying that an inherently O(N) operation
balloons into an O(N*N) operation.
--
Terry Jan Reedy
More information about the Python-list
mailing list