I\'m not able to find an effective way to pick out all permutations of 4 elements from a list of 9 elements in Haskell. The python-way to do the same thing:
Here is my solution:
import Control.Arrow
select :: [a] -> [(a, [a])]
select [] = []
select (x:xs) = (x, xs) : map (second (x:)) (select xs)
perms :: Int -> [a] -> [[a]]
perms 0 _ = [[]]
perms n xs = do
(y, ys) <- select xs
fmap (y:) (perms (n - 1) ys)
It's very lazy and even works for infinite lists, although the output there is not very useful. I didn't bother implementing diagonalization or something like that. For finite lists it's fine.