Skip to content

Instantly share code, notes, and snippets.

@dtak1114
Last active December 17, 2015 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtak1114/5619449 to your computer and use it in GitHub Desktop.
Save dtak1114/5619449 to your computer and use it in GitHub Desktop.
rotate function in haskell from mid-term 2010 exam
rotate x n
| n == 0 = x
| n >= (length x) = rotate x (mod n (length x))
| otherwise = rotate (tail x) (n-1) ++ [head x]
list = [5..8]
@dtak1114
Copy link
Author

$ ghci rotate.hs
rotate list 1
rotate list 10
rotate list 100000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment