Question : haskell get count of item in list
Answered by : open-ox-n180ly26l31g
-- 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
Source : | Last Update : Sun, 24 Apr 22