Created
January 22, 2012 20:36
-
-
Save anonymous/1658684 to your computer and use it in GitHub Desktop.
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
;; hans's solution to Rotate Sequence | |
;; https://4clojure.com/problem/44 | |
(fn [rot xs] | |
(let [rot (mod rot (count xs)) | |
rot (if (neg? rot) (+ (count xs) rot) rot)] | |
(loop [rot rot at-end [] x (first xs) xs (rest xs)] | |
(if (= rot 0) | |
(concat (cons x xs) at-end) | |
(recur (dec rot) (conj at-end x) (first xs) (rest xs)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment