Thanks Jed,

replicateM is almost as performant as pms on my pc (+ 2~ seconds).

That's a killer suggestion... thank you very much ^_^

--Cetin Sert

On 27/01/2008, Jed Brown <jed@59a2.org> wrote:
> The problem you solved can be solved much more elegantly:
>
> pms : [a] -> Int -> [[a]]
> pms xs n = foldM combine [] (replicate n xs) where
> combine rest as = liftM (:rest) as
>
> or, for the unreadable version:
> pms xs n = foldM (map . flip (:)) [] $ replicate n xs

or, if you don't mind getting the elements in a different order:

  replicateM 3 [True,False]

Jed

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe