Created
March 2, 2011 05:33
-
-
Save jColeChanged/850531 to your computer and use it in GitHub Desktop.
Naive Implementation of rotate left and rotate right.
This file contains 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
(defn rotatel | |
([n col] | |
(let [n (mod n (count col))] | |
(concat | |
(drop n col) | |
(take n col)))) | |
([col] | |
(rotatel 1 col))) | |
(defn rotater | |
([n col] | |
(let [n (mod n (count col))] | |
(concat | |
(take-last n col) | |
(drop-last n col)))) | |
([col] | |
(rotater 1 col))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment