Re: How to replace code inside a macro

2014-03-04 Thread milinda
I tried this. But couldn't achieve what I wanted. Below is the macro I wrote by utilizing macro let (defmacro [body] (let [x (gensym 'tu) defpop-decl (list 'defpop [] x)] `(macrolet [~defpop-decl] (defn execute [~x] ~body I wanted macro to work like

Re: Accumulate results without state?

2014-03-04 Thread Nick Gonzalez
It depends on what you want to do. If you really want to reduce the collection to an error count, then this will do it. (let [count-if (comp count filter)] (count-if #(re-matches pattern %) (line-seq rdr))) On Tuesday, March 4, 2014 4:21:47 PM UTC-5, Dean Laskin wrote: > > I'm comparing two l

Re: Clojure performance question

2014-03-04 Thread Mikera
On Wednesday, 5 March 2014 08:19:26 UTC+8, Jarrod Swart wrote: > > > On Monday, March 3, 2014 11:35:58 AM UTC-5, Mikera wrote: >> >> >> Obviously, there are cases where allocating a sequence will be slower >> than iterative techniques. But that's *easy enough to fix by just using >> iterations

Re: Clojure performance question

2014-03-04 Thread Jarrod Swart
On Monday, March 3, 2014 11:35:58 AM UTC-5, Mikera wrote: > > > Obviously, there are cases where allocating a sequence will be slower than > iterative techniques. But that's *easy enough to fix by just using > iterations in those cases* use the right tool for the job and all > that. > > I

Re: [ANN] Stasis - not another static site framework

2014-03-04 Thread Jarrod Swart
This is a cool project. I primarily use static site generators to build the front-end for sites that I will use enlive to template inside my app. I currently use: http://harpjs.com for this purpose because it allows easy integration of LESS and Jade which are auto recompiled & watched by the de

Re: Accumulate results without state?

2014-03-04 Thread Andrey Antukh
Hi! An other possible solution is using state monad from https://github.com/clojure/algo.monads Greetings. Andrey 2014-03-05 0:48 GMT+01:00 Jean Niklas L'orange : > Hello, > > > On Tuesday, March 4, 2014 10:47:12 PM UTC+1, Jason Felice wrote: >> >> Something like >> >> (with-open [rdr (clojur

Re: Accumulate results without state?

2014-03-04 Thread Jean Niklas L'orange
Hello, On Tuesday, March 4, 2014 10:47:12 PM UTC+1, Jason Felice wrote: > > Something like > > (with-open [rdr (clojure.java.io/reader "/dev/errors-sunday.csv")] > (->> (line-seq rdr) > (filter #(re-matches #"...")) > (map #(nth (string/split % #",") 1 > > Will do what you

Re: Accumulate results without state?

2014-03-04 Thread Jarrod Swart
I do something very similar to this where I parse large CSVs and keep/discard rows of the CSV based on the values of columns. Like you I had a hard time "getting" how to use reduce beyond trivial implementations. I spent some time messing with reduce and learning how to construct more advanced

Re: Accumulate results without state?

2014-03-04 Thread Jason Felice
Your welcome! I just realized that, in this case, filter and map are good enough, but the general answer for threading state through the processing of a sequence is to use `reduce`. Coming from another language, it takes a while to realize how often the answer is to use reduce. -Jason On Tue,

Re: Accumulate results without state?

2014-03-04 Thread Dean Laskin
Awesome, thanks Jason! It looks much cleaner. Dean On Tuesday, March 4, 2014 4:47:12 PM UTC-5, Jason Felice wrote: > > Something like > > (with-open [rdr (clojure.java.io/reader "/dev/errors-sunday.csv")] > (->> (line-seq rdr) > (filter #(re-matches #"...")) > (map #(nth (stri

Re: Accumulate results without state?

2014-03-04 Thread Jason Felice
Something like (with-open [rdr (clojure.java.io/reader "/dev/errors-sunday.csv")] (->> (line-seq rdr) (filter #(re-matches #"...")) (map #(nth (string/split % #",") 1 Will do what you want. It's laziness to the rescue. On Tue, Mar 4, 2014 at 3:21 PM, Dean Laskin wrote:

[ANN] loco 0.1.0

2014-03-04 Thread Alex Engelberg
Hi everyone. About 6 months ago, I created a Constraint Programming library called CloCoP. It was a Clojure wrapper for a Java library, and it mostly maintained the "imperative" propagation style. However, I was recently inspired to rework the library to h

Accumulate results without state?

2014-03-04 Thread Dean Laskin
I'm comparing two large files based on specific fields in the files. Is there a functional way of accumulating the results without atoms? (And since I'm a newbie, any other advice is appreciated!) (let [sun (atom []) fri (atom [])] (with-open [rdr (clojure.java.io/reader "/dev/errors-sunday.cs

Re: [ANN] Gorilla REPL initial release (0.1.2)

2014-03-04 Thread kovas boguta
On Tue, Mar 4, 2014 at 8:39 AM, François Rey wrote: > Great project! > I just watched this interesting video on reinventing the REPL which also > talks about notebook/graphical REPL. This was further developed at > Clojure/con 2012, and there's a project called Session on github. The response to

Re: How to replace code inside a macro

2014-03-04 Thread milinda
Thanks Jason. I'll try this. Milinda On Tuesday, March 4, 2014 1:35:39 PM UTC-5, Jason Felice wrote: > > Can you use macrolet from here: https://github.com/clojure/tools.macro ? > > > On Tue, Mar 4, 2014 at 11:30 AM, milinda > > wrote: > >> I wanted to achive following inside a macro. Lets say

Re: How to replace code inside a macro

2014-03-04 Thread Jason Felice
Can you use macrolet from here: https://github.com/clojure/tools.macro ? On Tue, Mar 4, 2014 at 11:30 AM, milinda wrote: > I wanted to achive following inside a macro. Lets say I have a macro > called deffilter which can use in following manner. > > (deffilter split-sentence ["sentence"] ["word"

How to replace code inside a macro

2014-03-04 Thread milinda
I wanted to achive following inside a macro. Lets say I have a macro called deffilter which can use in following manner. (deffilter split-sentence ["sentence"] ["word"] (work {} (let [tuple (pop) words (s/split (value-at tuple 0) " ")]

Lapse - a JSON property test generator

2014-03-04 Thread Aaron France
Hi, https://github.com/AeroNotix/lapse I've started work on a little project which intends to generate property tests (using core.test.check) from JSON schemas. The idea is that you supply it a schema and it would output a generator for that schema. This is a very, very young project but I'm

Re: [ANN] Gorilla REPL initial release (0.1.2)

2014-03-04 Thread François Rey
Great project! I just watched this interesting video on reinventing the REPL which also talks about notebook/graphical REPL. This was further developed at Clojure/con 2012 , and there's a project called Session on github <

Re: paredit+regex question

2014-03-04 Thread Oleh
Hi Erlis, There's a full alternative to Paredit that I'm writing: https://github.com/abo-abo/lispy. Try it out if you haven't yet, it's got some Clojure support, like inline function arguments and jump-to-defintion (just a binding for cider-jump-to-def, really, but it's just one letter: "F").

Re: paredit+regex question

2014-03-04 Thread Phillip Lord
Erlis Vidal writes: > Hi this is not a clojure question but I'm sure some one on this list can > help me. > > I'm trying to write a regex using paredit and it looks like I cannot write > something like this > > #"mypattern \d" > > whenever I type the character \ I see the text "Escaping character

Re: clojure lazy-seq caching?

2014-03-04 Thread Shantanu Kumar
On Tuesday, 4 March 2014 14:54:49 UTC+5:30, Andy Smith wrote: > > Does this mean that in a single threaded application lazy sequences suffer > the overhead of locks? I thought one of the features of clojure is that it > tries to avoid locks as much as possible. > The JIT compiler eliminates lo

Re: clojure lazy-seq caching?

2014-03-04 Thread Andy Smith
Does this mean that in a single threaded application lazy sequences suffer the overhead of locks? I thought one of the features of clojure is that it tries to avoid locks as much as possible. Andy -- You received this message because you are subscribed to the Google Groups "Clojure" group. To