http://d.puremagic.com/issues/show_bug.cgi?id=4705



--- Comment #4 from bearophile_h...@eml.cc 2010-12-24 22:53:27 PST ---
(In reply to comment #2)

> Aren't they "niche domain" tools?

The opposite is true. Functions and HOFs like max, min, sum, maxs, map, filter,
reduce, and so on are basic building blocks that are useful to build most other
programs. So their place is in the standard library, or sometimes even in the
language itself.


> Also, I wonder about maxs(collection) without any trnasform func: if you don't
> map, then there is logically a single max value (even if can occur several
> times in collection). maxS/minS seems useful only in presence of a transform
> func on which results comparison is done: the compared value is (in your case
> string len) unique, but there may be several original values in coll that map
> to it.
> To say it deifferently, in your case mins(collection) would return possibly
> multiple specimens of the same string. And mins(lenghts) would return [5,5].
> Unless I misunderstand your point.

maxs with no transform function is useful even with integers, to count how many
equal max values are present:

maxs([5, 1, 5, 3]).length == 2

And if your collection contains objects, they may compare as equal despite
being distinct.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to