Re:Examples of Incorrect Abstractions in Other Languages
by dragonwriter on Wednesday May 20, 2020 @11:07AM
(#23247740)
And that works in python to, even if the source type is strings:
sum(map(mappingFunction, iterable))
works fine as long as mappingFunction maps the elements of an iterable to numbers.
Computing the number of bytes used by a data type seems perfectly reasonable use of sum in that context. This is also achievable in many languages. All 'sum' needs is a map from a value to a number, which can have many sensible meanings even for arbitrary data types.