Last active
August 29, 2015 14:21
-
-
Save iporsut/3d02cb8bd88484012a49 to your computer and use it in GitHub Desktop.
rotate cycle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rotate xs n | n >= 0 = zipWith (\_ x -> x) xs $ drop n $ cycle xs | |
| otherwise = take len $ drop dropLen $ (cycle xs) | |
where | |
len = length xs | |
dropLen = (len + (n `mod` (-len))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment