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

javascript - IndexedDB error: Uncaught DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned -

amazon web services - When using Cognito credentials with AWS in a browser (javascript), keep getting "missing credentials" error -

c# - How to set the datatextfield value instead of the value on a drop down list? -