Hi!
A while back, I was implementing some datastructures using functions and
macros.
While implementing hashmaps, I stumbled upon a problem:
(ns hmap)
(defmacro hmap [& kvs]
"Returns an immutable hashmap.
Keys must be compile-time constants."
(if (even? (count kvs))
(let [tups (parti
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
@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
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
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
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
It is there to support the “:reload” and “:reload-all” features of “require”
and to help separate the concern of loading libs from the concern of tracking
namespaces.
--Steve
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, se
It is there to support the “:reload” and “:reload-all” features of “require”
and to help separate the concern of loading libs from the concern of tracking
namespaces.
--Steve
> On Jan 29, 2018, at 6:36 PM, Raymond Huang <12ay.hu...@gmail.com> wrote:
>
> I was poking around `tools.namespace` an
Can someone help me with the following please: I am new to clojure and i
haven't developed in 4 years, previous was mainframe. See questions in blue
; Task is to add full state name based on st_abbr
(def input-file [{:st_abbrev "AZ", :firstname "john", :lastname "smith"}
{:
*Clojure Developer*
Work with highly scaling back-end smart lighting IoT platform. The group
is a startup purchased by a large corporation (6-12+ contract through HCL),
so you get the best of both worlds.
Must Have:
--
1 to 3 years hands, production on experience in Clojure or another
First:
(#(map :st_abbrev input-file))
Is equivalent to:
(map :st_abbrev input-file)
Because your putting the form in an anonymous function, then immediately
calling it. This is equivalent to just evaluating the form.
Next, I think you're confused as to how `map` handles multiple arguments.
11 matches
Mail list logo