about summary refs log blame commit diff
path: root/assessments/brilliant/Utils.hs
blob: c69d00333b8e7e0c30a85986efc3caf8650ce9a3 (plain) (tree)
1
2
3
4
5
6
7
8







                                                                                




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