
23 Feb
2010
23 Feb
'10
7:03 a.m.
Rafael Gustavo da Cunha Pereira Pinto
While solving a puzzle, I was posed the problem of finding if there was no duplicates on a list.
First I used:
noneRepeated=null.(filter (>1)).(map length).group.sort
But this seemed very unneficient, so I thought that I could detect the duplicates while sorting, and devised this:
import Control.Monad import Data.Maybe
noneRepeated=isNothing . (foldl merge (Just [])) . (map sort) . pairs
import Data.List noneRepeated xs = xs == nub xs Greets Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/