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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -