Created
December 14, 2012 12:52
-
-
Save xavierRiley/4285276 to your computer and use it in GitHub Desktop.
Some ideas for the big scale exercise in Clojure
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 remove-consecutive-duplicates [coll] | |
| (let [shifted-coll (cons nil coll)] | |
| (remove nil? (map (fn [x y] (if (not= x y) x)) coll shifted-coll)))) | |
| (remove-consecutive-duplicates | |
| (seq | |
| (filter even? | |
| (take 32 | |
| (cycle | |
| (concat | |
| (range 0 10) | |
| (rest (reverse (rest (range 0 10)))))))))) | |
| ;; smush together 0123456789 with 87654321 then cycle | |
| ;; (0 2 4 6 8 6 4 2 0 2 4 6 8 6) | |
| ;;Infinite sequences are the tits | |
| (take 32 (remove-consecutive-duplicates (filter even? (seq (cycle (concat (range 0 10) (rest (reverse (rest (range 0 10)))))))))) | |
| ;; (0 2 4 6 8 6 4 2 0 2 4 6 8 6 4 2 0 2 4 6 8 6 4 2 0 2 4 6 8 6 4 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment