Problem with lazy seqs in macros

2018-02-05 Thread Divyansh Prakash
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

Re: Problem with lazy seqs in macros

2018-02-05 Thread Peter Hull
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

Re: Problem with lazy seqs in macros

2018-02-05 Thread Divyansh Prakash
@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

Re: Problem with lazy seqs in macros

2018-02-05 Thread Peter Hull
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

Re: Problem with lazy seqs in macros

2018-02-05 Thread Divyansh Prakash
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

Re: Problem with lazy seqs in macros

2018-02-05 Thread Divyansh Prakash
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

What does the ref *loaded-libs* do?

2018-02-05 Thread squeegee
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

Re: What does the ref *loaded-libs* do?

2018-02-05 Thread Stephen Gilardi
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

Help please: New to clojure development

2018-02-05 Thread Nadeen Kurz
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"} {:

[JOB] Clojure Developer for smart lighting IoT platform

2018-02-05 Thread Kevin
*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

Re: Help please: New to clojure development

2018-02-05 Thread James Reeves
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.