
26 Jan
2008
26 Jan
'08
6:03 p.m.
On 26 Jan 2008, ryani.spam@gmail.com 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