Re: Flow control in Clojure

2015-12-14 Thread dmichulke
The ring middleware has and solves this problem by using functions like this: (defn wrap-params [handler] (fn [req] (handler req))) So, basically you just have a function that takes a request and returns a response. This function is called a handler

Re: is there a community "best practice" for including your co-workers libraries?

2015-11-02 Thread dmichulke
You don't really need to set up a server infrastructure if you can live with hacks. One way is put the JAR say in a "/lib" dir and point the :resource-paths entry in profiles.clj directly to the JAR, so "lib/my-coworker-lib.jar". The other way is http://stackoverflow.com/a/26997656 but I only

Re: Rabid wild animals in my clojure argument lists, code gets infected.

2015-08-25 Thread dmichulke
Oh and (zero (count x)) is probably less idiomatic than (empty? x) -- 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

Re: Rabid wild animals in my clojure argument lists, code gets infected.

2015-08-25 Thread dmichulke
Sorry, I answered too quickly: The second one was wrong - this one ensures c and d are contained. (defn foo [a b {:keys [c d] :as m}] {:pre [(every? (partial contains? m) [:c :d]]} 1) And the last one was un-idiomatic - this one checks whether only c and d are contained. (defn foo [a b

Re: Rabid wild animals in my clojure argument lists, code gets infected.

2015-08-25 Thread dmichulke
If you have assertions enabled, you can declare (defn foo [a b {:keys [c d]}] {:pre [c d]} 1) to make sure that c and d are not nil (defn foo [a b {:keys [c d] :as m}] {:pre [(every? m [:c :d]]} 1) to make sure that c and d are contained and (defn foo [a b {:keys [c d] :as m}] {:pre

Re: zipmap different ordering in 1.7

2015-07-06 Thread dmichulke
The semantics of a set doesn't guarantee an order either (even though it's implementation might), I'd sort over the keys and use the resulting collection as hash-map key so you are independent of any clojure-intrinsic behavior. On Thursday, July 2, 2015 at 3:06:00 AM UTC+2, Fluid Dynamics