[Haskell-cafe] how can I select all the 3-element-combination out of a list efficiently

Mark T.B. Carroll mark at ixod.org
Mon May 21 09:33:43 EDT 2007


Mirko Rahn <rahn at ira.uka.de> writes:
(snip)
> Correct (and more natural):
>
> nOf 0 _      = [[]]
> nOf n (x:xs) = map (x:) (nOf (n-1) xs) ++ nOf n xs
> nOf _ []     = []

Thanks very much - in both claims you're indeed correct.

-- Mark



More information about the Haskell-Cafe mailing list