<< Back to previous view

[CLJ-1320] min-key assumes numbers, not comparables. Created: 09/Jan/14  Updated: 10/Jul/15  Resolved: 09/Jan/14

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2, Release 1.3, Release 1.4, Release 1.5, Release 1.6
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Pierre-Yves Ritschard Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None

Attachments: File min-key.diff    
Patch: Code


The min-key function assumes the key-fn will yield a number and thus uses the '<' operator to compare results.
There are cases where one might want to use min-key with comparables instead.

While (first (sort-by key-fn seq)) could also be used, it feels more natural for min-key to use comparables.

Comment by Pierre-Yves Ritschard [ 09/Jan/14 3:18 PM ]

As discussed on the .L, since compare is slower it makes more sense to keep min-key as-is.

Comment by Michael Blume [ 10/Jul/15 6:15 PM ]

Instead of changing min-key, would it make sense to have a different function which takes a comparator instead of a key function?

Generated at Mon Jan 22 04:29:36 CST 2018 using JIRA 4.4#649-r158309.