title: AtLeast occurrences in list
body: <p>I want to write a function that returns the list of elements that appeared at least n times in a list. It should work like this:</p>
  
  <pre><code>ghci&gt; atLeast [4,5,2,5,4,3,1,3,4] 2
  </code></pre>
  
  <p>output: <code>[5,3,4]</code></p>
  
  <p>My code:</p>
  
  <pre><code>count:: Eq a =&gt; a -&gt; [a] -&gt; Int
  count n [] = 0
  count n (h:t) | n == h = 1 + count n t
                | otherwise = count n t
  
  atLeast :: [Int] -&gt; Int -&gt; [Int]
  atLeast list min = nub $ filter (\b-&gt; count b list &gt;= min) list
  </code></pre>