<div dir="ltr">Not exactly that, but you can use groupBy fst . sort, then the head of the result list is your "minimumsBy" result.</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 26, 2018 at 6:28 AM Tom Ellis <<a href="mailto:tom-lists-haskell-cafe-2017@jaguarpaw.co.uk">tom-lists-haskell-cafe-2017@jaguarpaw.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Data.List.minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a<br>
<br>
<a href="https://www.stackage.org/haddock/lts-12.1/base-4.11.1.0/Data-List.html#v:minimumBy" rel="noreferrer" target="_blank">https://www.stackage.org/haddock/lts-12.1/base-4.11.1.0/Data-List.html#v:minimumBy</a><br>
<br>
but there are many cases where that's quite unhelpful. Actually what we<br>
want is more like<br>
<br>
minimumsBy :: ... => (a -> a -> Ordering) -> t a -> [a]<br>
<br>
There can be many distinct minimizers. For example when I want to get the<br>
collection of the youngest people from [(Age, Person)] I want<br>
<br>
minimumsBy (compare `on` fst) [(12, alice), (15, balaji), (12, cho)]<br>
<br>
to return<br>
<br>
[(12, alice), (12, cho)]<br>
<br>
Does "minimumsBy" exist somewhere reasonably standard? Hoogle doesn't throw<br>
up anything obvious<br>
<br>
<a href="https://www.stackage.org/lts-12.1/hoogle?q=%28a+-%3E+a+-%3E+Ordering%29+-%3E+t+a+-%3E+%5Ba%5D" rel="noreferrer" target="_blank">https://www.stackage.org/lts-12.1/hoogle?q=%28a+-%3E+a+-%3E+Ordering%29+-%3E+t+a+-%3E+%5Ba%5D</a><br>
<br>
Thanks,<br>
<br>
Tom<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>brandon s allbery kf8nh</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a></div></div></div></div></div>