tvl-depot/users/wpcarro/assessments/brilliant/Utils.hs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

14 lines
480 B
Haskell
Raw Normal View History

--------------------------------------------------------------------------------
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