title: get all possible combinations of k elements from a list
body: <p>I need a function that does the same thing as <a href="http://docs.python.org/3.3/library/itertools.html#itertools.combinations" rel="noreferrer"><code>itertools.combinations(iterable, r)</code> in python</a></p>
  
  <p>So far I came up with this:</p>
  
  <pre><code>{-| forward application -}
  x -: f = f x
  infixl 0 -:
  
  {-| combinations 2 "ABCD" = ["AB","AC","AD","BC","BD","CD"] -}
  combinations :: Ord a =&gt; Int -&gt; [a] -&gt; [[a]]
  combinations k l = (sequence . replicate k) l -: map sort -: sort -: nub
      -: filter (\l -&gt; (length . nub) l == length l)
  </code></pre>
  
  <p>Is there a more elegant and efficient solution?</p>