Created
March 15, 2010 13:20
-
-
Save chrisschreiner/332817 to your computer and use it in GitHub Desktop.
This file contains 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 range-without-zero [from to] | |
(filter #(not (= 0 %)) (range from to))) | |
(def my-range (range-without-zero -8 9)) | |
(def t-map-licoresse | |
(let [r (filter #(not (= 0 %)) (range -8 9))] | |
(concat (for [x r] [x -1]) | |
(for [x (reverse r)] | |
[x 1])))) | |
(def t-map-ulfster | |
(for [y '(1 -1) | |
x my-range :when (not= 0 x)] | |
[(* x y) (* -1 y)])) | |
(defn t-map-chouser [r] | |
(into {} (map #(vector %1 [%2 %3]) | |
(iterate inc 1) | |
(concat r (reverse r)) | |
(cycle [-1 1])))) | |
(defn t-map-2 [f] (into {} (map #(vector %1 %2) (range 1 (inc (count f))) f))) | |
(def result-of-computation | |
(t-map-2 t-map-ulfster)) | |
; => {32 [-8 1], 1 [-8 -1], 2 [-7 -1], 3 [-6 -1], 4 [-5 -1], 5 [-4 -1], 6 [-3 -1], 7 [-2 -1], 8 [-1 -1], 9 [1 -1], 10 [2 -1], 11 [3 -1], 12 [4 -1], 13 [5 -1], 14 [6 -1], 15 [7 -1], 16 [8 -1], 17 [8 1], 18 [7 1], 19 [6 1], 20 [5 1], 21 [4 1], 22 [3 1], 23 [2 1], 24 [1 1], 25 [-1 1], 26 [-2 1], 27 [-3 1], 28 [-4 1], 29 [-5 1], 30 [-6 1], 31 [-7 1]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment