Answers for "haskell how to delete duplicate element in list"

1

haskell how to delete duplicate element in list

rmdups :: (Ord a) => [a] -> [a]
rmdups l = map (head ( group ( sort l)))
-- first you sort the list, then you group all elements that are equal and then you take the first element of each list
Posted by: Guest on January-20-2022

Code answers related to "haskell how to delete duplicate element in list"

Browse Popular Code Answers by Language