99-haskell-problems/Problems 11-20/problem_19.hs

5 lines
129 B
Haskell

rotate :: [a] -> Int -> [a]
rotate l n =
if n >= 0
then (\(x, y) -> y ++ x) $ splitAt n l
else rotate l (length l + n)