You are viewing a single comment's thread. Return to all comments →
In what language? I did it in Haskell with:
rot :: String -> Int -> String rot s n = (drop n s) ++ (take n s)
In plain English, for (rot "abcde" 2), you skip the first 2 and get "cde" and you concatenate that with the first 2 "ab".
Rotate String
You are viewing a single comment's thread. Return to all comments →
In what language? I did it in Haskell with:
rot :: String -> Int -> String
rot s n = (drop n s) ++ (take n s)
In plain English, for (rot "abcde" 2), you skip the first 2 and get "cde" and you concatenate that with the first 2 "ab".