yaschk
yaschk

Reputation: 330

How to delete an element from list and all his duplicates?

I need to find max and min elements from list and remove them and their duplicate. I use

maximum(list)
minimum(list)

to find max and min but don't know how to remove all of them from a list.

Upvotes: 1

Views: 104

Answers (1)

munk
munk

Reputation: 12983

Filter will do what you need

removeMinAndMax xs = 
    filter (\x -> x /= listMin && x /= listMax) xs
    where listMin = minimum(xs)
          listMax = maximum(xs)

Upvotes: 2

Related Questions