News for hackers. Stuff that matters.
Re:Examples of Incorrect Abstractions in Other Languages by naasking on Wednesday May 20, 2020 @08:01AM (#23245817)
> There's no language in which you would be able to write a function for arbitrary data structures using sum(), and get a reasonable outcome.

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.

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.