Whats the issue with following pgm to find permutation of a string permute myStr = foldl(\acc x1 -> (foldr(\x2 acc1 -> (zipWith (\x3 y3 -> x3 ++ [x1] ++ y3) (inits acc1) (tails acc1))) [] acc)) [] myStr On Wed, Apr 29, 2009 at 6:35 PM, kaushal Pathak <kaushalkp@gmail.com> wrote:
Here is another one liner I am stuck at(Find permuation of string), here is my one line code :
permute myStr = foldr(\x acc -> (zipWith (\x1 y1 -> x1 ++ [x] ++ y1) (inits acc) (tails acc))) [] myStr
and here is 5 line error ;-(
Occurs check: cannot construct the infinite type: a = [a] Expected type: [a] Inferred type: [[a]] In the expression: (zipWith (\ x1 y1 -> x1 ++ x ++ y1) (inits acc) (tails acc)) In the first argument of `foldr', namely `(\ x acc -> (zipWith (\ x1 y1 -> x1 ++ x ++ y1) (inits acc) (tails acc)))'
Will really appreciate your help in moving ahead
Regards Kaushal