Answers for "haskell get count of item in list"

0

haskell get count of item in list

-- a has to be of type Eq
 -- works by filtering the list by that element, then counting the length
 
count :: Eq a => a -> [a] -> Int
count elem elements = length $ filter (==elem) elements
Posted by: Guest on April-17-2022

Code answers related to "haskell get count of item in list"

Browse Popular Code Answers by Language