Haskell Get Count Of Item In List

[Solved] Haskell Get Count Of Item In List | Haskell - Code Explorer | yomemimo.com
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

Answers related to haskell get count of item in list

Code Explorer Popular Question For Haskell