[Haskell-cafe] groupBy without Ord?

John Lato jwlato at gmail.com
Sun Mar 23 23:34:42 UTC 2014


I would keep in mind that, given the constraints

 - you want to group together all equal elements from the entire list
 - the only operation you can perform on elements is comparison for equality

your function will have quadratic complexity (at least I can't see any way
around it).  If there's any way of sorting the elements, even if the order
is entirely arbitrary, you should consider it.

John L.

On Sat, Mar 22, 2014 at 9:51 AM, martin <martin.drautzburg at web.de> wrote:

> Hello all,
>
> when I groupBy a list in order to cluster elements which satisfy some sort
> of equality, I usually have to sort the list
> first, which requires Ord. However groupBy itself does not require Ord,
> but just Eq.
>
> How can I groupBy a List whose elements are only instances of Eq but not
> of Ord?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140323/1c3e37bf/attachment.html>


More information about the Haskell-Cafe mailing list