[Haskell-beginners] Need Help
kaushal Pathak
kaushalkp at gmail.com
Wed Apr 29 09:44:21 EDT 2009
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 at 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
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090429/2442e1d8/attachment.htm
More information about the Beginners
mailing list