Skip to content

Instantly share code, notes, and snippets.

@iporsut
Last active August 29, 2015 14:21
Show Gist options
  • Save iporsut/3d02cb8bd88484012a49 to your computer and use it in GitHub Desktop.
Save iporsut/3d02cb8bd88484012a49 to your computer and use it in GitHub Desktop.
rotate cycle
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