
12 Feb
2009
12 Feb
'09
10:24 a.m.
On 12 Feb 2009, at 10:20, Jan Snajder wrote:
Hi!
I'm trying to write a list permutation function, and there is in fact a nice explanation of how to do it here: http://sneakymustard.com/2008/12/23/shuffling-in-haskell
But for the start I wanted to keep things simple and avoid monad transformers (since I'm not into this yet). Instead, I'd like to write a function of type:
permute :: [a] -> IO [a]
o.O Why not keep things simple and just write a pure function? permute :: [a] -> [[a]] permute xs = [s:ps | (s,ss) <- select xs, ps <- permute ss] select :: [a] -> [(a,[a])] select [] = [] select (x:xs) = (x,xs) : [(s,x:ss) | (s,ss) <- select xs] Bob