Last active
December 17, 2015 13:48
-
-
Save dtak1114/5619449 to your computer and use it in GitHub Desktop.
rotate function in haskell from mid-term 2010 exam
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 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] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ ghci rotate.hs
rotate list 1
rotate list 10
rotate list 100000000