diff options
Diffstat (limited to 'scratch/brilliant/Utils.hs')
-rw-r--r-- | scratch/brilliant/Utils.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/scratch/brilliant/Utils.hs b/scratch/brilliant/Utils.hs index 2f401af2fb8f..c69d00333b8e 100644 --- a/scratch/brilliant/Utils.hs +++ b/scratch/brilliant/Utils.hs @@ -6,3 +6,8 @@ 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 |