Created
August 10, 2012 13:05
-
-
Save xavierRiley/3314074 to your computer and use it in GitHub Desktop.
Revisions
-
xavierRiley revised this gist
Sep 1, 2012 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,13 +12,13 @@ ;(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))) ) ) -
xavierRiley revised this gist
Aug 13, 2012 . 1 changed file with 11 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,21 +12,24 @@ ;(get-dir (seq (range 10))) (defn saw-step [min max step direction] (when (= direction :up) (cycle (concat (range min max step) (range max min (- step))))) (when (= direction :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))) -
xavierRiley revised this gist
Aug 13, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,7 @@ (cycle (concat (range min max step) (range max min (- step))))) ;; Inspiration - http://osdir.com/ml/clojure/2010-04/msg00722.html (defn rotate-while "Rotates a collection left while (pred item) is true. Will return a -
xavierRiley revised this gist
Aug 13, 2012 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,4 +17,15 @@ (range max min (- 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)))) (get-dir (seq (take 12 (saw-step 5 15 1)))) (rotate-while #(>= 7 %) (take 12 (saw-step 5 15 1))) -
xavierRiley created this gist
Aug 10, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ (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] (cycle (concat (range min max step) (range max min (- step))))) (get-dir (seq (take 12 (saw-step 5 15 1))))