I defined a macro like this:
(defmacro randomly [& exprs]
(let [len (count exprs)
ind (rand-int len)
conditions (map #(list '= ind %) (range len))]
`(cond ~@(interleave conditions exprs))))
and then defined a function :
(defn randomly-fn [& exprs]
(randomly exprs))
I think there may be a mistake because of the randomly-fn didn't work
as expected.
(randomly-fn (print 1) (print 2) (print 3))
expected:
1 or 2 or 3.
but returned:
123
where is the mistake?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en