[Haskell-cafe] sort . nub (was Re: how to generate source code from TH Exp?)

Herbert Valerio Riedel hvr at gnu.org
Sun May 15 15:32:03 CEST 2011

On Thu, 2011-05-12 at 19:31 +0200, Daniel Fischer wrote:
> > Minor nitpick:  instead of doing 'sort . nub', please use 'import
> > qualified Data.Set as S' and do 'S.toAscList . S.fromList'.  This
> > should be a lot faster.
> Or `map head . group . sort', which may be faster than building an 
> intermediate Set (haven't benchmarked, may be faster, slower or mkae no 
> difference).

if the input list has _many_ duplicates, wouldn't using 'map head .
group . sort' require more memory than going the 'toAscList . fromList'

More information about the Haskell-Cafe mailing list