about summary refs log tree commit diff
path: root/users/wpcarro/assessments/brilliant/Utils.hs
diff options
context:
space:
mode:
Diffstat (limited to 'users/wpcarro/assessments/brilliant/Utils.hs')
-rw-r--r--users/wpcarro/assessments/brilliant/Utils.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/users/wpcarro/assessments/brilliant/Utils.hs b/users/wpcarro/assessments/brilliant/Utils.hs
new file mode 100644
index 000000000000..c69d00333b8e
--- /dev/null
+++ b/users/wpcarro/assessments/brilliant/Utils.hs
@@ -0,0 +1,13 @@
+--------------------------------------------------------------------------------
+module Utils where
+--------------------------------------------------------------------------------
+import Data.Function ((&))
+--------------------------------------------------------------------------------
+
+(|>) :: a -> (a -> b) -> b
+(|>) = (&)
+
+-- | Rotate `xs` as a cycle `n` times.
+rotate :: Int -> [a] -> [a]
+rotate n xs = take size . drop (n `mod` size) . cycle $ xs
+  where size = length xs