[Haskell-cafe] Re: Function to detect duplicates

Daniel Fischer daniel.is.fischer at web.de
Tue Feb 23 09:08:56 EST 2010

Am Dienstag 23 Februar 2010 14:54:36 schrieb Jonas Almström Duregård:
> You are correct of course. Still, it will probably be a bit less
> inefficient if the length of the lists are compared (as opposed to the
> elements):
> noneRepeated xs = length xs == length (nub xs)

Only if no repeated elements appear early.
For xs = 1 : [1 .. 10^7], xs == nub xs will return False without noticeable 
delay, length xs == length (nub xs) will take VERY long.

More information about the Haskell-Cafe mailing list