Re: clojure.java.jdbc and joined tables

2013-02-17 Thread Sean Corfield
You should get col and col_1 automatically since it looks for duplicate column names and makes them unique. Which version of java.jdbc are you using? On Sun, Feb 17, 2013 at 8:46 PM, Alex Baranosky wrote: > I have an issue with clojure.java.jdbc, in that I want to join two tables > that have colu

clojure.java.jdbc and joined tables

2013-02-17 Thread Alex Baranosky
I have an issue with clojure.java.jdbc, in that I want to join two tables that have columns with the same name. What's happening is that the result set maps only have the second key-value pair from the result row in them. Is there some way to alias or namespace the keywords in the results from cl

Re: with-redefs for vars in a different namespace for tests (midje facts)

2013-02-17 Thread Leonardo Borges
Hi, So I got a working test and it looks like this: (facts "sets a value for the given key in redis" (with-redefs [redis/with-conn (constantly "Ok")] (require '[com.leonardoborges.cache :as cache] :reload) (fact "with no ttl " (cache/set "key" "value") =>

Re: RC 16: Last chance to test against Clojure 1.5 before it ships

2013-02-17 Thread Dave Sann
timely comment. you can create and throw it but catching it requires the imported type. (not withstanding catching the generic Exception on the JVM). see the link for suggestion/discussion on making this more "uniform" for clj and cljs: https://groups.google.com/d/topic/clojurescript/A3wH_Hm3O

with-redefs for vars in a different namespace for tests (midje facts)

2013-02-17 Thread Leonardo Borges
Hi, I have some caching code that relies on a macro called 'with-redis' so while writing my tests I'd like to redef this macro to bypass all of it's redis connection machinery and just execute a function that does nothing instead. Something like this works: (with-redefs [cache/with-redis (fn [&

Re: Clojure count and get functions much faster on strings than direct interop with .length and .charAt

2013-02-17 Thread Geo
Clojure is full of pleasant surprises :) > > -- -- 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. T

Re: alternative to passing parameters to functions

2013-02-17 Thread vemv
fn's "keyword arguments" feature provide unrolled, optional key-value args: (defn foo [& {:keys [a b c]}] [a b c]) (foo :c 4) ;; [nil nil 4] On Sunday, February 17, 2013 10:06:13 PM UTC+1, AtKaaZ wrote: > > Was there a library or some other way to pass ie. maps to functions > so that the order

alternative to passing parameters to functions

2013-02-17 Thread AtKaaZ
Was there a library or some other way to pass ie. maps to functions so that the order of the params isn't predefined, just in case I want to skip some passing parameters without actually having to pass some value for them, I could just refer to which params I'm passing by identifying them with a :k

Re: Using local jar

2013-02-17 Thread Jarod
James, Aaron and Jim: thanks for your help, but it still get the old error message and another: "Leiningen managed dependencies issue: problem resolving following dependencies: [jaad/jaad "0.8.4"]". If anyone has time, my lein version is 1.7.1 and maven version is 2.2.1 and I used the followin

Re: Clojure count and get functions much faster on strings than direct interop with .length and .charAt

2013-02-17 Thread Akhil Wali
What's happening is a classic example of "Functional Lisp FTW" :P On Sun, Feb 17, 2013 at 7:47 PM, Geo wrote: > I am writing an expensive algorithms in Clojure and while trying to > optimize the code I discovered something that puzzled me. Clojure count and > get functions are much faster on st

Re: Clojure count and get functions much faster on strings than direct interop with .length and .charAt

2013-02-17 Thread AtKaaZ
and in the case of String, this happens: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L547 else if(o instanceof CharSequence) return ((CharSequence) o).length(); => (dorun (map println (supers (class "a string here" java.lang.Object java.

Re: λ machine as a d3 tree, parsed with PEG

2013-02-17 Thread AtKaaZ
it's about time, now let's see that in 3d and with clojure structures :) On Sun, Feb 17, 2013 at 7:40 PM, Rich Morin wrote: > Some folks here may enjoy this: > > λ machine as a d3 tree, parsed with PEG > http://brycec.github.com/vizlamb/ > > -r > > -- > http://www.cfcl.com/rdmR

λ machine as a d3 tree, parsed with PEG

2013-02-17 Thread Rich Morin
Some folks here may enjoy this: λ machine as a d3 tree, parsed with PEG http://brycec.github.com/vizlamb/ -r -- http://www.cfcl.com/rdmRich Morin http://www.cfcl.com/rdm/resume r...@cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Software system design, develop

Re: RC 16: Last chance to test against Clojure 1.5 before it ships

2013-02-17 Thread vemv
ah nice, never realised that, thank you. still it'd be somewhat more consistent to import ExceptionInfo: (throw (Exception.)) (throw (IndexOutOfBoundsException.)) (throw (IllegalArgumentException.)) ;; ...there's quite clearly a pattern here, which many are accustomed to (throw (ex-info "" {})) ;

Re: Clojure count and get functions much faster on strings than direct interop with .length and .charAt

2013-02-17 Thread Herwig Hochleitner
2013/2/17 Geo > So how come Clojure's get and count don't incur the reflection penalty? Clojure's collection functions do a typeof dispatch for JVM types. In a bootstrapped clojure, that would be solved with protocols. E.g. https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT

Re: RC 16: Last chance to test against Clojure 1.5 before it ships

2013-02-17 Thread Baishampayan Ghose
You can create an ExceptionInfo instance easily by using the core fn `ex-info`. So something like ... (throw (ex-info {:foo "bar"})) works fine. ~BG On Sun, Feb 17, 2013 at 10:05 PM, vemv wrote: > Couldn't clojure.lang.ExceptionInfo be imported by default? That'd surely > help making ExceptionInf

Re: RC 16: Last chance to test against Clojure 1.5 before it ships

2013-02-17 Thread vemv
Couldn't clojure.lang.ExceptionInfo be imported by default? That'd surely help making ExceptionInfo the idiomatic exception to be thrown. On Thursday, February 14, 2013 4:33:42 AM UTC+1, stuart@gmail.com wrote: > > If you care about Clojure 1.5 compatibility for your codebase, please test >

Re: Clojure count and get functions much faster on strings than direct interop with .length and .charAt

2013-02-17 Thread Geo
Thank you! Adding type hints solves the problem. The interop now slightly outperforms Clojure's get and count. So how come Clojure's get and count don't incur the reflection penalty? On Sunday, February 17, 2013 9:17:55 AM UTC-5, Geo wrote: > > I am writing an expensive algorithms in Clojure an

ANN Neocons 1.1.0-beta4 is released

2013-02-17 Thread Michael Klishin
Neocons [1] is a feature rich idiomatic Clojure client for the Neo4J REST API. 1.1.0-beta4 is a milestone release with one bug fix. Release notes are at http://blog.clojurewerkz.org/blog/2013/02/17/neocons-1-dot-1-0-beta4-is-released/ 1. http://clojureneo4j.info -- MK http://github.com/michaelk

Re: Clojure count and get functions much faster on strings than direct interop with .length and .charAt

2013-02-17 Thread Akhil Wali
Tried it out. user> (time (dotimes [_ 1000] (.length ^String sss))) "Elapsed time: 0.341035 msecs" user> (time (dotimes [_ 1000] (.length ^String sss))) "Elapsed time: 0.341105 msecs" user> (time (dotimes [_ 1000] (.length ^String sss))) "Elapsed time: 0.356121 msecs" user> (time (dotimes [_ 1000]

Re: Clojure count and get functions much faster on strings than direct interop with .length and .charAt

2013-02-17 Thread Nicola Mometto
Try to set! *warn-on-reflection* to true and you'll find out that there's a lot of reflection going on when using direct java interop. Try benchmarking (.length ^String sss) and you'll see the difference Geo writes: > I am writing an expensive algorithms in Clojure and while trying to > optimiz

Clojure count and get functions much faster on strings than direct interop with .length and .charAt

2013-02-17 Thread Geo
I am writing an expensive algorithms in Clojure and while trying to optimize the code I discovered something that puzzled me. Clojure count and get functions are much faster on strings than direct interop with .length and .charAt. On my machine I get the following: (def sss (apply str (repeat 1

Re: Why is this so difficult?

2013-02-17 Thread Michael Klishin
2013/2/17 Jim - FooBar(); > "clojure-doc.org" ?? > OMG, is this new? it seems to have some gorgeous tutorials for newcomers > It has been up since October 2012. Not much activity recently but except for macros, all the essentials are pretty well covered already. -- MK http://github

Re: Why is this so difficult?

2013-02-17 Thread Mayank Jain
It's been around for quite some time actually but not known to many people still. On Sun, Feb 17, 2013 at 4:43 PM, Jim - FooBar(); wrote: > "clojure-doc.org" ?? > OMG, is this new? it seems to have some gorgeous tutorials for > newcomers...LIke Bizics, i had no idea this site existe

Re: Using local jar

2013-02-17 Thread Jim - FooBar();
Even though what Aaron said is correct, I'll just add that with lein2 you can get away with not "installing" your jar in ~/.m2/. Just use the :resource-paths key in your project.clj and point to a folder with 'orphan' jars...something like this: :resource-paths ["orphan-jars/*"] ;;all jars un

Re: Why is this so difficult?

2013-02-17 Thread Jim - FooBar();
"clojure-doc.org" ?? OMG, is this new? it seems to have some gorgeous tutorials for newcomers...LIke Bizics, i had no idea this site existed! How come google is not showing this in the first page when typing "Clojure docs" or something like that? I'm definately bookmarking this...

ANN Langohr 1.0.0-beta11

2013-02-17 Thread Michael Klishin
Langohr [1] is a Clojure RabbitMQ client that embraces AMQP 0.9.1 Model [2]. Release notes for beta11: http://blog.clojurewerkz.org/blog/2013/02/17/langohr-1-dot-0-0-beta11-is-released/ 1. http://clojurerabbitmq.info 2. http://www.rabbitmq.com/tutorials/amqp-concepts.html -- MK http://github.co

Re: Why is this so difficult?

2013-02-17 Thread BJG145
...agreed, the introduction to CCW at: http://clojure-doc.org/articles/tutorials/eclipse.html ...is simple enough even for me to understand, and I'm now happy that CCW is working. I'd previously tried: http://dev.clojure.org/display/doc/Getting+Started+with+Eclipse+and+Counterclockwise ...whic