Re: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Timothy Baldridge
Touching the accumulator (the result in your case) from within a transducing function is a bit of an anti-pattern. The whole point of transducers is that you can swap out the accumulator: (transduce (map inc) conj [] (range 10)) (transduce (map inc) async/>! some-channel (range 10)) (transduce (ma

Re: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Travis Daudelin
On Friday, June 10, 2016 at 3:03:38 PM UTC-7, Francis Avila wrote: > > A higher-order function can do what this macro does: > https://gist.github.com/favila/ecdd031e22426b93a78f > Oh nice! It looks like I came up with an almost identical solution: (defn transducing [f] (fn [reducing-fn] (

Re: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Francis Avila
A higher-order function can do what this macro does: https://gist.github.com/favila/ecdd031e22426b93a78f On Friday, June 10, 2016 at 1:07:58 PM UTC-5, Travis Daudelin wrote: > > Hi all! > > I'm current working on a project where I am ingesting events off a stream > and processing them. There ar

Clojars will be partially down for maintenance this weekend

2016-06-10 Thread Toby Crawley
At 2016-06-13 00:00:00 UTC[1], we'll be taking down the Clojars web interface to do database maintenance and deploy some features/fixes. The biggest change in this deploy will be the introduction of sending a copy of deployed artifacts to Rackspace CloudFiles to allow us to serve the repository fro

Re: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Travis Daudelin
Actually, I spoke too soon. It looks like completing takes in a reducing function and wraps it so that it meets the arity expectations of a transducer. While this is still super useful to my needs (thanks again!) I wanted to clarify for posterity that completing does not solve the issue in my i

[ANN] angel-interceptor 0.3.0 - express relations between Pedestal interceptors

2016-06-10 Thread Oliver Hine
Hi all, Following on from the release of pedestal 0.5.0 I'm pleased to say that angel-interceptor is now compliant as of v0.3.0, available now on Clojars. Cheers Oliy -- You received this message because you are subscribed to the Google Groups "Clo

Re: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Travis Daudelin
On Friday, June 10, 2016 at 11:43:04 AM UTC-7, Bobby Eickhoff wrote: > > But maybe the core function completing is very close to what you're > looking for... > Hmm, looking through its source I'd say it's exactly what I'm looking for. Thank you! -- You received this message because you are

Re: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Travis Daudelin
> > I think you can do what you want with existing transducers. Won't > map/filter/keep/etc do the trick? > I can't say for sure that it's not possible, but I certainly lack the imagination :). The logic I need to write is quite complicated and I'm finding it's easier to write my own transduce

Re: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Bobby Eickhoff
Having spent quite a bit of time recently dissecting transducers , I'd tend to agree with Tim: core transducers will probably give you most of what you want. I'd also agree that writing macros should be your last reso

Re: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Nate Young
You can "capture" symbols from the surrounding context, making them available to the body of your macros, the "tilde tick trick" is what you're looking for there: (defmacro deftransducer [body] `(fn [reducing-fn#] (fn ([] (reducing-fn#))

Re: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Raoul Duke
My $0.02 is only resort to macros when all else has failed. Can just higher order functions and composition and injection get you closer to what you want? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goo

Re: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Timothy Baldridge
I think you can do what you want with existing transducers. Won't map/filter/keep/etc do the trick? On Fri, Jun 10, 2016 at 7:06 PM, Travis Daudelin wrote: > Hi all! > > I'm current working on a project where I am ingesting events off a stream > and processing them. There are many many steps inv

Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Travis Daudelin
Hi all! I'm current working on a project where I am ingesting events off a stream and processing them. There are many many steps involved in the processing component, so I am choosing to write the steps as a series of transducers (because, hey, they're super cool!). Here's the problem though, a

Re: why is it so annoying to run clojure code

2016-06-10 Thread John Gabriele
On Thursday, June 9, 2016 at 12:08:39 PM UTC-4, Jiacai Liu wrote: > > I started learning clojure recently, and I am annoyed at the way to run > it (aka. lein run). why clojure script can't be run like python,ruby or > scala, like python .py > I suggest using [Inlein](http://inlein.org/) for thi

Re: why is it so annoying to run clojure code

2016-06-10 Thread Andrea Richiardi
On Thursday, June 9, 2016 at 1:59:40 PM UTC-7, hiskennyness wrote: > > > Having just gotten into Clojure, I have the same pain. But I am a long > time Lisper, so I understand that this just means that Clojure is a true > Lisp, because Lisps punish noobs in cruel and unusual ways. > > And, yes, sp

Re: clojure.spec: hard to generate sequential things

2016-06-10 Thread Frank Versnel
Thanks for the quick and clear answer flipping (s/* integer?) and sequential? indeed did the trick. On Friday, June 10, 2016 at 5:19:29 PM UTC+2, Alex Miller wrote: > > sequential? is not really adding any value here - using a regex op will > *only* match something that's sequential. > > The oth

Re: clojure.spec: hard to generate sequential things

2016-06-10 Thread Alex Miller
sequential? is not really adding any value here - using a regex op will *only* match something that's sequential. The other thing to know here is that s/and creates a generator that generates based on the first spec, then filters based on the subsequent ones. So if you wanted to do sequences of

clojure.spec: hard to generate sequential things

2016-06-10 Thread Frank Versnel
Hi, I'm currently playing around with clojure spec trying to write a spec for an old program I wrote and stumbled upon the following: Whenever I try to generate something that is both sequential and something else it doesn't really work most of the time. For example when I try to create a seque

Re: why is it so annoying to run clojure code

2016-06-10 Thread Brent Millare
You can run it like python, ruby, etc. https://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips Basically, at the top of a clj file, put: ":";exec /path/to/java -cp "/path/to/clojure.jar" clojure.main $0 "$@" (ns command-line-args) (defn command-line? []

Re: clojure.spec and s/keys + s/fdef problem

2016-06-10 Thread Steen Larsen
Ahh, thanks a lot. Was confused that valid? worked fine, but didn't know about args being a sequence Den fredag den 10. juni 2016 kl. 15.19.48 UTC+2 skrev Alex Miller: > > You want: > > (s/fdef command > :args (s/cat :m (s/keys :req [::test]) > :ret string?) > > :args takes a sequ

Re: clojure.spec and s/keys + s/fdef problem

2016-06-10 Thread Alex Miller
You want: (s/fdef command :args (s/cat :m (s/keys :req [::test]) :ret string?) :args takes a sequence of the arguments as if you were going to apply it. On Friday, June 10, 2016 at 7:58:10 AM UTC-5, Steen Larsen wrote: > > Hi, > > I am playing around with spec, and really like it

Re: clojure.spec and s/keys + s/fdef problem

2016-06-10 Thread Fluid Dynamics
On Friday, June 10, 2016 at 8:58:10 AM UTC-4, Steen Larsen wrote: > > Hi, > > I am playing around with spec, and really like it so far, but have a > problem using fdef with maps. I am obviously missing something trivial, but > the following example gives a, to me, weird error > > (defn command [m

clojure.spec and s/keys + s/fdef problem

2016-06-10 Thread Steen Larsen
Hi, I am playing around with spec, and really like it so far, but have a problem using fdef with maps. I am obviously missing something trivial, but the following example gives a, to me, weird error (defn command [m] "hello") (s/def ::test integer?) (s/fdef command :args (s/keys :re