Imagine a map m { "foo" [1 2 3 4] "bar" [\a \b \c] "baz" [true false] }
How could I transform that into a seq s ( {"foo" 1 "bar" \a "baz" true} {"foo" 1 "bar" \a "baz" false} {"foo" 1 "bar" \b "baz" true} {"foo" 1 "bar" \b "baz" false} {"foo" 1 "bar" \c "baz" true} {"foo" 1 "bar" \c "baz" false} {"foo" 2 "bar" \a "baz" true} ... ) I've made a macro to expand the map over a for: (defmacro cartesian-map [m] `(for ~(vec (reduce #(concat %1 %2) (map #(identity [(symbol %) (list 'coordinates %)]) (keys coordinates)))) ~(apply hash-map (flatten (map #(identity [% (symbol %)]) (keys coordinates)))))) and expands correctly: (clojure.core/for [foo (coordinates "foo") bar (coordinates "bar") baz (coordinates "baz")] {"foo" foo, "bar" bar, "baz" baz}) but when I run it, I only get (), which doesn't make any sense because if I run the expansion against the map m, it performs correctly. Why would the macro expand correctly, but no run correctly in the REPL? Also, are there any ways to simplify my macro? Rob -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en