Re: Optimizing JDBC code

2011-08-08 Thread Dmitry Gutov
Like the doc says, `with-query-results` takes additional options before the query string. In your case, it should be something like this: (sql/with-query-results recs `[{:fetch-size 1000} ~query-str ~@bvs] (doall recs)) -- You received this message because you are subscribed to the Google Gr

Re: ClojureScript binding problem

2011-08-01 Thread Dmitry Gutov
Oh, thanks for the explanation. I looked at the twitterbuzz code before replying, saw the function calls with arguments written the usual way, and (erroneously) decided it would be the same for the zero-arity calls. But it's there in the wiki. On Aug 1, 5:17 pm, Chouser wrote: > In Clojure you a

Re: java.lang.OutOfMemoryError when consuming many whole-numbers

2011-08-01 Thread Dmitry Gutov
When I do that, the REPL starts printing the sequence, filling screens after screens with numbers. By doing that, it realizes the printed part of the sequence, which will eventually lead to an OOM error, since it probably holds on to the reference to the start of the sequence. Doing (set! clojure.

Re: ClojureScript binding problem

2011-08-01 Thread Dmitry Gutov
On Aug 1, 1:32 pm, Brian McKenna wrote: > For anyone else with the same problem, I just found the nice way to do it: > >     (def iframe (. field (getEditableIframe))) This should be equivalent to (def iframe (.getEditableIframe field)) which is the usual way to do method calls on the host langua

Re: How to write `when-lets`

2011-07-27 Thread Dmitry Gutov
> First: Why doesn't macroexpand expand the inner when-lets? It's not supposed to, see the doc. To do full expansion, you can use `clojure.walk/macroexpand-all`. > Is the gensym in the two expands the same thing, or do "they" get the > same name? That was surprising to me. I can't think of any re

Re: How to write `when-lets`

2011-07-27 Thread Dmitry Gutov
This would be a straightforward solution: (defmacro when-lets [bindings & body] `(let ~bindings (when (and ~@(map first (partition 2 2 bindings))) ~@body))) It works well in simple cases, but breaks e.g. in case of parameter destructuring. If you read `(source when-let)`, you'll see

Re: casting and type declaration

2011-07-25 Thread Dmitry Gutov
Type annotations are used at compile time to generate direct method calls (as opposed to using reflection). `cast` is a function, so it doesn't do anything until runtime, and it just delegates to Class#cast. I don't think it is used much. In the core, it's only called in single- arity cases for *

Re: Why is this code so slow?

2011-07-25 Thread Dmitry Gutov
On Jul 25, 10:54 am, Oskar wrote: > On Jul 23, 4:06 pm, Dmitry Gutov wrote: > > > Ahem. > > > Here is a more idiomatic version that runs under half a second, no > > annotations required. > > I did that from the beginning, but as I really needed 4e6 and not 1e5

Re: Why is this code so slow?

2011-07-23 Thread Dmitry Gutov
Ahem. Here is a more idiomatic version that runs under half a second, no annotations required. (def vs (atom {})) (defn sk [k] (if (@vs k) (@vs k) (let [ans (if (< k 56) (- (mod (+ 13 (- (* k 23)) (* 37 k k k)) 100) 50

Re: Why is this code so slow?

2011-07-23 Thread Dmitry Gutov
hould be much faster than the > previous one even with recursion, right? > > On Jul 22, 10:51 pm, Dmitry Gutov wrote: > > > > > > > > > In case the two replies above didn't drive the point home, the Python > > version is not recursive (it uses results

Re: Why is this code so slow?

2011-07-22 Thread Dmitry Gutov
In case the two replies above didn't drive the point home, the Python version is not recursive (it uses results memoized in the data array). So, not the same thing. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to c

Re: what makes this code slow?

2011-07-21 Thread Dmitry Gutov
The first version stops as soon it encounters the first item in the collection that's too big. The second version filters the whole collection, which may lead to a major slowdown, depending on coll's relative size. It will also hang if coll is infinite. This should be better: (take-while #(<= % lim

Re: Sample Vaadin application in Clojure

2011-07-02 Thread Dmitry Gutov
> Is there any hope of getting rid of the servlet altogether, and > somehow get a Ring handler to perform whatever Vaadin stuff that needs > to be done on the server? Well, you could rewrite the servlet in Clojure... right? Aside from that, I don't think so. Ring works on a much lower level of abs

Re: Other way to express (((m2) 2) 1)?

2011-06-29 Thread Dmitry Gutov
You can use 'reduce': (reduce nth m [2 2 1]) ;; or, for the general case (reduce #(%1 %2) m [2 2 1]) On Jun 30, 3:20 am, Antonio Recio wrote: > (get-in m [2 2 1]) is great! Which are the others ones? Is there something > like (-> m [2 2 1])? -- You received this message because you are subscri

Re: Today is "Get Your App on Clojure 1.2" Day

2010-08-01 Thread Dmitry Gutov
That's leiningen bug 62: http://github.com/technomancy/leiningen/issues/closed/#issue/62 It should be fixed in trunk. On Jul 31, 2:33 am, Bootvis wrote: > There seems to be a problem with the RC on Windows. I was > followinghttp://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applica..