Thanks Jed,<br><br>replicateM is almost as performant as pms on my pc (+ 2~ seconds).<br><br>That's a killer suggestion... thank you very much ^_^<br><br>--Cetin Sert<br><br><div><span class="gmail_quote">On 27/01/2008, <b class="gmail_sendername">Jed Brown</b> <<a href="mailto:jed@59a2.org">jed@59a2.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> The problem you solved can be solved much more elegantly:<br>><br>> pms : [a] -> Int -> [[a]]<br>> pms xs n = foldM combine [] (replicate n xs) where<br>> combine rest as = liftM (:rest) as<br>><br>
> or, for the unreadable version:<br>> pms xs n = foldM (map . flip (:)) [] $ replicate n xs<br><br>or, if you don't mind getting the elements in a different order:<br><br> replicateM 3 [True,False]<br><br>Jed<br>
<br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br><br></blockquote></div><br>