Created
July 30, 2015 11:52
-
-
Save mishok13/be3e4d93933c259c59b2 to your computer and use it in GitHub Desktop.
Steps in
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
(defn from-to | |
"For two integers create a sequence [a, a+x, ..., b, b) where x may be 1 or -1" | |
[a b] | |
(let [step (if (pos? (- a b)) -1 1)] | |
(concat (range a b step) (repeat b)))) | |
(defn from-to-seq | |
[x y] | |
(let [max-distance (->> (map - x y) (map #(Math/abs %)) (apply max))] | |
(->> (map from-to x y) | |
(map (partial take max-distance)) | |
(apply map vector)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment