Skip to content

Instantly share code, notes, and snippets.

Created January 22, 2012 20:36
Show Gist options
  • Save anonymous/1658684 to your computer and use it in GitHub Desktop.
Save anonymous/1658684 to your computer and use it in GitHub Desktop.
;; 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