Is there a way to generated pre-filtered permutations, that is rather than doing :
filter condition $ permutations list
the permutation function can short-circuit. For example :
perms [] = [[]]
perms xs = [ i:j | i <- xs, j <- perms $ delete i xs]
I tried a few obvious things like :
perms xs = [ i:j | i <- xs, j <- filter condition $ perms $ delete i xs]
I thought what would happen is this would set off a chain which would end up at []
and then work back up, but filtering along the way. However when feeding it a long list and thus speeding up the process. This doesn't seem to happen as it bogged out (ghci) when trying to do a permutation of a 20 item list that would have only very few actually filtered permutations.