summaryrefslogtreecommitdiff
path: root/11-20/19.hs
diff options
context:
space:
mode:
Diffstat (limited to '11-20/19.hs')
-rw-r--r--11-20/19.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/11-20/19.hs b/11-20/19.hs
new file mode 100644
index 0000000..f1e795b
--- /dev/null
+++ b/11-20/19.hs
@@ -0,0 +1,6 @@
+rotate :: [a] -> Int -> [a]
+
+rotate l n = let (a, b) = rot l (if n < 0 then (n + length l) else n) in b ++ a
+ where rot l@(x:xs) n
+ | n > 0 = let (a, b) = rot xs (n - 1) in (x:a, b)
+ | otherwise = ([], l)