Permutation of string, Haskell -
this question exact duplicate of:
i have given string: abcdpqrs, output be: badcqpsr.
my current code:
f :: [a] -> [a] f (a:b:xs) = b:a:xs f xs = xs
evaluating f "abcdpqrs"
results in "bacdpqrs"
. how can used "badcqpsr"?
try processing more first 2 characters recursing on remainder of list:
f :: [a] -> [a] f (a:b:xs) = b:a:f xs f xs = xs
Comments
Post a Comment