Determine presence of duplicates in a list of any data type in Haskell -


is there function in haskell take in list of data type (specifically string) , check whether there repeated elements in list, i.e. repeated letters in string?

the nub function data.list module

nub :: (eq a) => [a] -> [a] 

removes duplicates have been seen in list, , preserves order otherwise.

ghci> nub [1,3,5,3,6,5] [1,3,5,6] 

you can use function write function looking simple one-liner. because of laziness, it's efficient can when using eq constraint! (you can better if require ord, though)


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -