(defn get-dir [x] (let [penul (first (rest (reverse x)))]) (let [final (last x)]) (when (> (first (rest (reverse x))) (last x)) (print "down")) (when (> (last x) (first (rest (reverse x)))) (print "up")) ) ;(get-dir (seq (range 10))) (defn saw-step [min max step dir] (case dir :up (cycle (concat (range min max step) (range max min (- step)))) :down (cycle (concat (range max min (- step)) (range min max step))) ) ) (defn rotate-while "Rotates a collection left while (pred item) is true. Will return a unrotated sequence if (pred item) is never true. Executes in O(n) time." [pred coll] (let [head (drop-while pred coll)] (take (count coll) (concat head coll)))) (print (seq (take 12 (saw-step 5 16 1 :up)))) ;; (rotate-while #(>= 7 %) (take 12 (saw-step 5 15 1 :up)))