I am writing a function that checks if a list containts an element at least N times
atLeastNtimes :: Eq a => Int -> a -> [a] -> Bool
atLeastNtimes n a l = n <= (sum [1 | x <- l, (x == a)])
It is working fine with finite list, but I am struggling to make this work for infinite lists, for example:
atLeastNtimes 100 'a' (repeat 'a')