Created
January 23, 2017 23:02
-
-
Save amalloy/304c33342b468c6fe05c97822f427077 to your computer and use it in GitHub Desktop.
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
(letfn [(part [n] | |
[(list `quote (symbol (str "step-" n))), | |
`(count (doto ~'coll (.add ~n)))])] | |
`(let [~'coll (java.util.LinkedList.)] | |
~(apply array-map (mapcat part (range 10))))) | |
;; eval the result of the previous form: | |
user> (eval (letfn [(part [n] | |
[(list `quote (symbol (str "step-" n))), | |
`(count (doto ~'coll (.add ~n)))])] | |
`(let [~'coll (java.util.LinkedList.)] | |
~(apply array-map (mapcat part (range 10)))))) | |
{step-5 6, step-0 1, step-2 3, step-8 9, step-3 4, step-7 8, step-1 2, step-6 7, step-4 5, step-9 10} | |
;; copy-paste the result of the previous form into the repl instead: | |
user> (let [coll (java.util.LinkedList.)] | |
{(quote step-0) (count (doto coll (.add 0))), | |
(quote step-1) (count (doto coll (.add 1))), | |
(quote step-2) (count (doto coll (.add 2))), | |
(quote step-3) (count (doto coll (.add 3))), | |
(quote step-4) (count (doto coll (.add 4))), | |
(quote step-5) (count (doto coll (.add 5))), | |
(quote step-6) (count (doto coll (.add 6))), | |
(quote step-7) (count (doto coll (.add 7))), | |
(quote step-8) (count (doto coll (.add 8))), | |
(quote step-9) (count (doto coll (.add 9)))}) | |
{step-5 9, step-0 10, step-2 2, step-8 1, step-3 4, step-7 3, step-1 5, step-6 8, step-4 7, step-9 6} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment