And yes, take-nth is what I wanted!
--
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
that (:a :b) *really* looks like a seq
--
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 unsubscri
You could (I think) simplify to:
(defmacro hmap [& kvs]
"Returns an immutable hashmap.
Keys must be compile-time constants."
(if (even? (count kvs))
(let [keys (into [] (take-nth 2) kvs)]
`(fn [k#]
(case k# ~@kvs ::keys ~keys)))
(throw (Exception. "hmap takes an EVEN n
@Peter Great catch, thanks! I was scratching my head over this.
--
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
On Monday, 5 February 2018 09:22:58 UTC, Divyansh Prakash wrote:
You see what's happening with macroexpand
(macroexpand '(hmap :a 1 :b 2))
(fn* ([k__4009__auto__] (clojure.core/case k__4009__auto__ :a 1 :b 2
:user/keys [:a :b])))
versus
(fn* ([k__4146__auto__] (clojure.core/case k__4146__aut