require and :require
hi all, What's the difference between these two snippets? 1. (ns my-ns (require [package.name.a])) 2. (ns my-ns (:require [package.name.a])) They all works!But I wonder what's the differences between them. thx! -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: require and :require
By coincidence they are both equivalent and expand to exactly the same code. The latter is preferred, and it's debatable if the former should even be legal. Thanks, Ambrose On Fri, Dec 6, 2013 at 5:07 PM, BillZhang wrote: > hi all, > What's the difference between these two snippets? > > 1. > (ns my-ns > (require [package.name.a])) > > 2. > (ns my-ns > (:require [package.name.a])) > > They all works!But I wonder what's the differences between them. > > thx! > > -- > -- > 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. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
require & :require
hi all, What's the differences between those two snippets? 1. (ns a (require [a.b])) 2. (ns a (:require [a.b])) They all works in my code! thx~ -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: require & :require
I believe one is a directive and the other is a function.:require doesn't need the values to be quoted (:require xyz)require needs values to be quoted so that they're not evaluated when passed as arguments (require 'xyz)I could be wrong though. 06.12.2013, 18:17, "BillZhang" :hi all,What's the differences between those two snippets?1.(ns a (require [a.b])) 2.(ns a (:require [a.b])) They all works in my code! thx~ -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: How would I do this in Clojure?
> > Hi Folks > firstly a big thank you for all the help so far. I posted the original question because I've been looking at Midje which has the ability to stub out a function but have the stub function return different data each time it is called (it also counts the number of times the stubbed out function is called). Still being a Clojure newbie (and having heard that the Midje codebase is complex) I thought I'd ask how this could be done. I know about with-redefs so figured out how to stub a function but was struggling with calling something that returned a set of values. So basically this is a learning exercise for me. cheers Dave -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: require & :require
Inside the ns form they are the same. Outside the ns form, only (require '[a.b]) works (with quoting, as Kelker said). Jonathan On Fri, Dec 6, 2013 at 10:24 AM, Kelker Ryan wrote: > I believe one is a directive and the other is a function. > > :require doesn't need the values to be quoted > > (:require xyz) > > require needs values to be quoted so that they're not evaluated when > passed as arguments > > (require 'xyz) > > I could be wrong though. > > 06.12.2013, 18:17, "BillZhang" : > > hi all, > What's the differences between those two snippets? > 1. > (ns a > (require [a.b])) > > 2. > (ns a > (:require [a.b])) > > They all works in my code! > > thx~ > > > -- > -- > 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. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > -- > -- > 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. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
java.jdbc not working with my jdbc driver
Hi I have our own jdbc driver when I am trying to use clojure java.jdbc it is giving me error like below Exception in thread "main" java.lang.ClassCastException: a.b.my_custom_driver cannot be cast to clojure.lang.IFn at clojure.gemfireXD.jdbc$createStatement.invoke(client.clj:13) at clojure.gemfireXD.jdbc$eval13.invoke(client.clj:18) at clojure.lang.Compiler.eval(Compiler.java:6619) at clojure.lang.Compiler.load(Compiler.java:7064) at clojure.lang.Compiler.loadFile(Compiler.java:7020) at clojure.main$load_script.invoke(main.clj:294) at clojure.main$script_opt.invoke(main.clj:356) at clojure.main$main.doInvoke(main.clj:440) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.lang.Var.invoke(Var.java:415) at clojure.lang.AFn.applyToHelper(AFn.java:161) at clojure.lang.Var.applyTo(Var.java:532) at clojure.main.main(main.java:37) When I tried following (ns clojure.custom.jdbc (:import [java.sql Connection DriverManager]) (:require [clojure.string :as clojure-string])) (defn getConnecton [url] (clojure.lang.RT/loadClassForName "custom.url.ClientDriver") (DriverManager/getConnection url)) (defn createStatement [db] (^Statement (.createStatement db) )) (createStatement((getConnecton "jdbc:mydbServer://localhost:1527/"))) Exception in thread "main" java.lang.ClassCastException: my.custom.implementation.internal.ConnectionCustom cannot be cast to clojure.lang.IFn at clojure.gemfireXD.jdbc$eval13.invoke(client.clj:16) at clojure.lang.Compiler.eval(Compiler.java:6619) at clojure.lang.Compiler.load(Compiler.java:7064) at clojure.lang.Compiler.loadFile(Compiler.java:7020) at clojure.main$load_script.invoke(main.clj:294) at clojure.main$script_opt.invoke(main.clj:356) at clojure.main$main.doInvoke(main.clj:440) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.lang.Var.invoke(Var.java:415) at clojure.lang.AFn.applyToHelper(AFn.java:161) at clojure.lang.Var.applyTo(Var.java:532) at clojure.main.main(main.java:37) What I am missing here. -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: java.jdbc not working with my jdbc driver
Parenthesis call the thing they wrap as a function. You have getConnection wrapped in a redundant set of parenthesis, so the return value of getConnection is being called. It is not a function, but it is a ConnectionCustom, so you get your error. Some hints to make clojure code more readable: classes should be CamelCase, methods should be camelCase, functions should be kabob-case. parens should be separated by a preceding item by a space - (f (g x)) - g and x are not args to f, (g x) is the arg to f no line should contain only parens On Friday, December 6, 2013 5:08:23 AM UTC-8, Avinash Dongre wrote: > > Hi > I have our own jdbc driver when I am trying to use clojure java.jdbc it is > giving me error like below > > Exception in thread "main" java.lang.ClassCastException: > a.b.my_custom_driver cannot be cast to clojure.lang.IFn > at clojure.gemfireXD.jdbc$createStatement.invoke(client.clj:13) > at clojure.gemfireXD.jdbc$eval13.invoke(client.clj:18) > at clojure.lang.Compiler.eval(Compiler.java:6619) > at clojure.lang.Compiler.load(Compiler.java:7064) > at clojure.lang.Compiler.loadFile(Compiler.java:7020) > at clojure.main$load_script.invoke(main.clj:294) > at clojure.main$script_opt.invoke(main.clj:356) > at clojure.main$main.doInvoke(main.clj:440) > at clojure.lang.RestFn.invoke(RestFn.java:408) > at clojure.lang.Var.invoke(Var.java:415) > at clojure.lang.AFn.applyToHelper(AFn.java:161) > at clojure.lang.Var.applyTo(Var.java:532) > at clojure.main.main(main.java:37) > > > When I tried following > > > > (ns clojure.custom.jdbc > (:import [java.sql Connection DriverManager]) > (:require [clojure.string :as clojure-string])) > > (defn getConnecton > [url] > (clojure.lang.RT/loadClassForName "custom.url.ClientDriver") > (DriverManager/getConnection url)) > > (defn createStatement > [db] > (^Statement (.createStatement db) > )) > > > (createStatement((getConnecton "jdbc:mydbServer://localhost:1527/"))) > > Exception in thread "main" java.lang.ClassCastException: > my.custom.implementation.internal.ConnectionCustom cannot be cast to > clojure.lang.IFn > at clojure.gemfireXD.jdbc$eval13.invoke(client.clj:16) > at clojure.lang.Compiler.eval(Compiler.java:6619) > at clojure.lang.Compiler.load(Compiler.java:7064) > at clojure.lang.Compiler.loadFile(Compiler.java:7020) > at clojure.main$load_script.invoke(main.clj:294) > at clojure.main$script_opt.invoke(main.clj:356) > at clojure.main$main.doInvoke(main.clj:440) > at clojure.lang.RestFn.invoke(RestFn.java:408) > at clojure.lang.Var.invoke(Var.java:415) > at clojure.lang.AFn.applyToHelper(AFn.java:161) > at clojure.lang.Var.applyTo(Var.java:532) > at clojure.main.main(main.java:37) > > > What I am missing here. > -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: java.jdbc not working with my jdbc driver
To add some further clarification to the style hints suggested: many of us read code in multiple languages, and using formatting that is idiomatic to the language being used helps us keep the rules straight. f(a b) is an algol family syntax, the lisp family has a direct equivalent of (f a b), when you type out (f a (g b)) in a lisp as (f a(g b)) you cause many readers to do a double take, because it looks like an algol family function invocation on a (which is not being invoked as a function in our lisp syntax). Similar issues with camelCase versus kabob-case - If things are named unconventionally I have to slow down and double check whether the thing in question is really a method or a function (because they follow very different rules). And the same with trailing parenthesis - this is standard idiom in algol family languages, but when included in lisp family code, I have to slow down and consciously read it as lisp, rather than automatically knowing which I am seeing based on the paren placement. On Friday, December 6, 2013 5:30:57 AM UTC-8, Justin Smith wrote: > > Parenthesis call the thing they wrap as a function. You have getConnection > wrapped in a redundant set of parenthesis, so the return value of > getConnection is being called. It is not a function, but it is a > ConnectionCustom, so you get your error. > > Some hints to make clojure code more readable: > > classes should be CamelCase, methods should be camelCase, functions should > be kabob-case. > > parens should be separated by a preceding item by a space - (f (g x)) - g > and x are not args to f, (g x) is the arg to f > > no line should contain only parens > > On Friday, December 6, 2013 5:08:23 AM UTC-8, Avinash Dongre wrote: >> >> Hi >> I have our own jdbc driver when I am trying to use clojure java.jdbc it >> is giving me error like below >> >> Exception in thread "main" java.lang.ClassCastException: >> a.b.my_custom_driver cannot be cast to clojure.lang.IFn >> at clojure.gemfireXD.jdbc$createStatement.invoke(client.clj:13) >> at clojure.gemfireXD.jdbc$eval13.invoke(client.clj:18) >> at clojure.lang.Compiler.eval(Compiler.java:6619) >> at clojure.lang.Compiler.load(Compiler.java:7064) >> at clojure.lang.Compiler.loadFile(Compiler.java:7020) >> at clojure.main$load_script.invoke(main.clj:294) >> at clojure.main$script_opt.invoke(main.clj:356) >> at clojure.main$main.doInvoke(main.clj:440) >> at clojure.lang.RestFn.invoke(RestFn.java:408) >> at clojure.lang.Var.invoke(Var.java:415) >> at clojure.lang.AFn.applyToHelper(AFn.java:161) >> at clojure.lang.Var.applyTo(Var.java:532) >> at clojure.main.main(main.java:37) >> >> >> When I tried following >> >> >> >> (ns clojure.custom.jdbc >> (:import [java.sql Connection DriverManager]) >> (:require [clojure.string :as clojure-string])) >> >> (defn getConnecton >> [url] >> (clojure.lang.RT/loadClassForName "custom.url.ClientDriver") >> (DriverManager/getConnection url)) >> >> (defn createStatement >> [db] >> (^Statement (.createStatement db) >> )) >> >> >> (createStatement((getConnecton "jdbc:mydbServer://localhost:1527/"))) >> >> Exception in thread "main" java.lang.ClassCastException: >> my.custom.implementation.internal.ConnectionCustom cannot be cast to >> clojure.lang.IFn >> at clojure.gemfireXD.jdbc$eval13.invoke(client.clj:16) >> at clojure.lang.Compiler.eval(Compiler.java:6619) >> at clojure.lang.Compiler.load(Compiler.java:7064) >> at clojure.lang.Compiler.loadFile(Compiler.java:7020) >> at clojure.main$load_script.invoke(main.clj:294) >> at clojure.main$script_opt.invoke(main.clj:356) >> at clojure.main$main.doInvoke(main.clj:440) >> at clojure.lang.RestFn.invoke(RestFn.java:408) >> at clojure.lang.Var.invoke(Var.java:415) >> at clojure.lang.AFn.applyToHelper(AFn.java:161) >> at clojure.lang.Var.applyTo(Var.java:532) >> at clojure.main.main(main.java:37) >> >> >> What I am missing here. >> > -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: require & :require
You might find this useful: http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: ANNOUNCE: Cognitect is sponsoring "CinC" contrib libraries
This is great news! :) On Thu, Dec 5, 2013 at 3:42 PM, Nicola Mometto wrote: > > I'm happy to announce that after Ambrose BS commissioned me to continue > working on my "CinC" libraries as part of his typed-clojure campaign > (http://www.indiegogo.com/projects/typed-clojure), Cognitect > (http://cognitect.com/) offered me sponsorship for my work on "CinC" > contrib libraries. > > The libraries I'm referring to with "CinC" libraries are: > * tools.analyzer: https://github.com/clojure/tools.analyzer > * tools.analyzer.jvm: https://github.com/clojure/tools.analyzer.jvm > * tools.emitter.jvm: https://github.com/clojure/tools.emitter.jvm > > > I want to thanks Justin Gehtland and Tim Baldridge that helped this > happen and Alex Miller for his prompt help in setting up the JIRA and > Hudson workflows. > > Thanks again to Ambrose BS and a bit unrelately I want to thanks Andy > Fingerhut who lately has been a great help to me, trying out > tools.analyzer[.jvm] and reporting bugs along the way. > > Thanks, > Nicola Mometto (Bronsa) > > -- > -- > 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. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: ANNOUNCE: Cognitect is sponsoring "CinC" contrib libraries
That's awesome! --- Joseph Smith j...@uwcreations.com @solussd > On Dec 6, 2013, at 8:44 AM, David Nolen wrote: > > This is great news! :) > > >> On Thu, Dec 5, 2013 at 3:42 PM, Nicola Mometto wrote: >> >> I'm happy to announce that after Ambrose BS commissioned me to continue >> working on my "CinC" libraries as part of his typed-clojure campaign >> (http://www.indiegogo.com/projects/typed-clojure), Cognitect >> (http://cognitect.com/) offered me sponsorship for my work on "CinC" >> contrib libraries. >> >> The libraries I'm referring to with "CinC" libraries are: >> * tools.analyzer: https://github.com/clojure/tools.analyzer >> * tools.analyzer.jvm: https://github.com/clojure/tools.analyzer.jvm >> * tools.emitter.jvm: https://github.com/clojure/tools.emitter.jvm >> >> >> I want to thanks Justin Gehtland and Tim Baldridge that helped this >> happen and Alex Miller for his prompt help in setting up the JIRA and >> Hudson workflows. >> >> Thanks again to Ambrose BS and a bit unrelately I want to thanks Andy >> Fingerhut who lately has been a great help to me, trying out >> tools.analyzer[.jvm] and reporting bugs along the way. >> >> Thanks, >> Nicola Mometto (Bronsa) >> >> -- >> -- >> 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. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. > > -- > -- > 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. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: ANNOUNCE: Cognitect is sponsoring "CinC" contrib libraries
This is great news. Congratulations and many thanks to Cognitect for making it possible! '(Devin Walters) On Dec 5, 2013, at 14:42, Nicola Mometto wrote: > > I'm happy to announce that after Ambrose BS commissioned me to continue > working on my "CinC" libraries as part of his typed-clojure campaign > (http://www.indiegogo.com/projects/typed-clojure), Cognitect > (http://cognitect.com/) offered me sponsorship for my work on "CinC" > contrib libraries. > > The libraries I'm referring to with "CinC" libraries are: > * tools.analyzer: https://github.com/clojure/tools.analyzer > * tools.analyzer.jvm: https://github.com/clojure/tools.analyzer.jvm > * tools.emitter.jvm: https://github.com/clojure/tools.emitter.jvm > > > I want to thanks Justin Gehtland and Tim Baldridge that helped this > happen and Alex Miller for his prompt help in setting up the JIRA and > Hudson workflows. > > Thanks again to Ambrose BS and a bit unrelately I want to thanks Andy > Fingerhut who lately has been a great help to me, trying out > tools.analyzer[.jvm] and reporting bugs along the way. > > Thanks, > Nicola Mometto (Bronsa) > > -- > -- > 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. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[ANN] Penny Black
https://github.com/flyingmachine/penny-black Penny Black allows you to declaratively create functions which send HTML and text emails using mustache templates. It's inspired by ActionMailer. You might find it useful if you have an application that sends email :) Here's an example of defining and then calling an email function (taken from the github readme): ;; it's necessary to require both the correct backend and ;; com.flyingmachine.penny-black.core.send in order to define your senders ;; Why? Becase v0.1.0 (ns whatever (:require com.flyingmachine.penny-black-apache-commons [com.flyingmachine.penny-black.core.send :refer (defsenders)])) ;; Create the sending functions. Example of calling them below. (defsenders ;; A list of args that each sending function will take {:args [users topic] :user-doseq [user users]} ;; senders iterate over a seq and send an email for each element ;; :user-doseq specifies which argument from :args corresponds to ;; the seq ("users") and what name to use for each element ("user"). ;; This way you have access to element when specifying the data to ;; bind to your email templates, e.g. (:user/username user) below ;; These are defaults which you can overwrite in each sender below. ;; If you specify :body-data in a sender, it gets merged with the ;; map you supply here. {:to (:user/email user) :body-data {:topic-title (:title topic) :topic-id (:id topic) :username (:user/username user)}} ;; Each sending function can specify additional args. This function ;; will take [users topic post] (send-reply-notification [post] :from "custom-f...@for-this-sender.com" :subject (str "[Forum Site] Re: " (:title topic)) :body-data {:content (:content post) :formatted-content (markdown-content post)}) (send-new-topic-notification [] :subject (str "[Forum Site] " (:title topic)) :body-data {:content (:content (:first-post topic)) :formatted-content (markdown-content (:first-post topic))})) ;; Example of calling (let [post some-post topic (:topic post) users (db/all [:users :watching topic])] (send-reply-notification users topic post)) Thanks! Daniel https://twitter.com/nonrecursive -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Import dbpedia data into neo4j using clojure
Glad it worked, if you have any further questions feel free to ask. I'm using it extensively and it and Clojure seem to be a perfect match these days, especially on very large datasets. --Joseph On Friday, December 6, 2013 12:56:40 AM UTC-6, Himakshi Mangal wrote: > > Hi Joseph Guhlin, > > Thanks your idea helped and i could send some sample data to my neo4j > database. > > Thank you very much... :) > > > On Monday, December 2, 2013 3:41:53 PM UTC+5:30, Himakshi Mangal wrote: >> >> Hi... >> >> >> I am using clojure to import dbpedia data into neo4j. >> >> Here's the code: >> (ns opal.dbpedia >> (:use [clojure.tools.logging :only [log]]) >> (:require [clojure.java.io :as io]) >> (:import [uk.ac.manchester.cs.owl.owlapi.turtle.parser TurtleParser] >>[org.neo4j.unsafe.batchinsert BatchInserters] >>[org.neo4j.graphdb DynamicRelationshipType])) >> >> ;; PARSING METHODS >> >> (defn get-next-tuple >> [parser] >> (let [last-item (atom nil) >> tuple (atom [])] >> (while (and (not= "." @last-item) >> (not= "" @last-item)) >> (reset! last-item >> (-> parser >> (.getNextToken) >> (.toString))) >> (swap! tuple conj @last-item)) >> (when-not (empty? (first @tuple)) ; .getNextToken returns "" once you >> are out of data >> @tuple))) >> >> (defn seq-of-parser >> [parser] >> (if-let [next-tuple (get-next-tuple parser)] >> (lazy-cat [next-tuple] >> (seq-of-parser parser >> >> (defn parse-file >> [filename] >> (seq-of-parser >> (TurtleParser. >> (io/input-stream filename >> >> ;; BATCH UPSERT METHODS >> >> (def id-map (atom nil)) >> (defn insert-resource-node! >> [inserter res] >> (if-let [id (get @id-map res)] >> ; If the resource has aleady been added, just return the id. >> id >> ; Otherwise, add the node for the node, and remember its id for later. >> (let [id (.createNode inserter {"resource" res})] >> (swap! id-map #(assoc! % res id)) >> id))) >> >> (defn connect-resource-nodes! >> [inserter node1 node2 label] >> (let [relationship (DynamicRelationshipType/withName label)] >> (.createRelationship inserter node1 node2 relationship nil))) >> >> (defn insert-tuple! >> [inserter tuple] >> ; Get the resource and label names out of the tuple. >> (let [[resource-1 label resource-2 & _ ] tuple >> ; Upsert the resource nodes. >> node-1 (insert-resource-node! inserter resource-1) >> node-2 (insert-resource-node! inserter resource-2)] >> ; Connect the nodes with an edge. >> (connect-resource-nodes! inserter node-1 node-2 label))) >> >> (defn -main [graph-path & files] >> (let [inserter (BatchInserters/inserter graph-path)] >> (doseq [file files] >> (log :debug (str "Loading file: " file)) >> (let [c (atom 0)] >> (doseq [tuple (parse-file file)] >> (if (= (mod @c 1) 0) >> (log :debug (str file ": " @c))) >> (swap! c inc) >> (insert-tuple! inserter tuple >> (log :debug "Loading complete.") >> (log :debug "Shutting down.") >> (.shutdown inserter) >> (log :debug "Shutdown complete!"))) >> >> I am getting the following errors: >> >> IllegalAccessError Transient used by non-owner thread >> clojure.lang.PersistentArrayMap$TransientArrayMap.ensureEditable >> (PersistentArrayMap.java:449) >> >> && >> >> >> IllegalArgumentException No matching method found: createNode for class >> org.neo4j.unsafe.batchinsert.BatchInserterImpl >> clojure.lang.Reflector.invokeMatchingMethod >> >> >> Can anyone please help me in this.. Am doing something wrong or am i >> missing something.. I am completely new to clojure. Is there a working >> example for this? >> >> >> Please help.. >> >> Thanks >> >> >> -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Function to Generate EDN :readers Map for Namespace Records?
I use a default reader to do something like what you're asking for in my 'tagged' library. You could hack a similar default reader that restricted itself just to your favorite namespaces. That way you don't have to explicitly track all your defrecord classes. https://github.com/miner/tagged On Fri, Dec 6, 2013 at 2:10 AM, Michael Daines wrote: > I'm trying to come up with a function that will take a namespace > containing Record definitions and convert it into a :readers map for EDN > parsing. Right now, I'm just doing it manually, but as the number of > records grows, this feels sillier and sillier. I haven't found anything in > the core libraries yet that would seem to help me here. The only "ns-" > function that gets me some of what I need is (ns-publics), which I could > use to parse out the map functions. > > To be more clear, I have a namespace in the project like this: > > (ns proj.core.records) > > (defrecord NodeAddress [node address]) > (defrecord NodeComplete [node completed status) > ... etc. > > > Then at the end of the file, I'm manually creating a map for use with EDN: > > (def reader-map > {'proj.core.records.NodeAddress map->NodeAddress >... etc. }) > > > I feel like there should be an elegant way to do this, but I haven't seen > anything like what I have in mind. I'd love to put together a general > purpose function I could use like this: > > (edn/read-string {:readers (reader-map 'proj.core.records)} data) > > > Does anyone have some insights, or suggestions, or maybe something out > there already (this seems to me like an obvious thing to do)? > > Thanks > > -- > -- > 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. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Possible core.async timeout issue
Good day everyone, I inadvertently passed a double to a timeout channel and discovered the following behavior: user=> (require '[clojure.core.async :as a]) nil user=> (a/timeout 100.0) # user=> Exception in thread "clojure.core.async.timers/timeout-daemon" java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Long at java.lang.Long.compareTo(Long.java:50) at java.util.concurrent.ConcurrentSkipListMap.doRemove(ConcurrentSkipListMap.java:1064) at java.util.concurrent.ConcurrentSkipListMap.remove(ConcurrentSkipListMap.java:1896) at clojure.core.async.impl.timers$timeout_worker.invoke(timers.clj:61) at clojure.lang.AFn.run(AFn.java:24) at java.lang.Thread.run(Thread.java:722) user=> (.isAlive clojure.core.async.impl.timers/timeout-daemon) false I'm using 0.1.242.0-44b1e3-alpha. -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [ANN] Buffy The ByteBuffer Slayer, Clojure library to working with binary data
@Rob I have a working prototype of bits, which are encoded from 32 flags and decoded back to them. I've added a couple of helper methods such as `set-bits-at` and `get-set-bits` and so on to facilitate it. Although I recommend using enums for that (which is possible in majority of cases). I'll release it shortly and will give an additional notice @Ulisses Yes, that's been missing in the released version. I'll add it shortly. Working on a patch, should be available by monday. You can always fork & add it, we love patches! @Cesar I haven't planned to do any dynamic payloads, although I'll add a couple of examples on how I'm doing same thing while parsing Cassandra protocol. Since their types are dynamic (for instance, string type consists of long and sequence of ASCII chars), I do have some version remotely resembling what you mention. Although since I haven't yet found an elegant way, I can only provide a hint on how to implement it. Will provide docs for that together with the rest of patches in work. On Wed, Dec 4, 2013 at 3:58 PM, Rob Day wrote: > On 29 November 2013 22:15, Alex P wrote: > > Buffy [1] is a Clojure library to work with Binary Data, write complete > > binary protocol implementations > > in clojure, store your complex data structures in an off-heap chache, > read > > binary files and do > > everything you would usually do `ByteBuffer`. > > Is there any plan to support bit-fields? My main interest at present > is the Diameter protocol, where some individual bits in the header are > true/false flags - Gloss decodes that nicely into a sequence of bools, > but I can't see similar support in Buffy. > > -- > -- > 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. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- alex p -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [ANN] Buffy The ByteBuffer Slayer, Clojure library to working with binary data
@Thomas, let me know if you run into any problems. Since the project is quite young, I'm very open to add a couple of features. Rob, Ulisses and Cesar have done a very nice job providing some very nice ideas! On Sat, Dec 7, 2013 at 12:05 AM, Oleksandr Petrov < oleksandr.pet...@gmail.com> wrote: > @Rob > I have a working prototype of bits, which are encoded from 32 flags and > decoded back to them. I've added a couple of helper methods such as > `set-bits-at` and `get-set-bits` and so on to facilitate it. > Although I recommend using enums for that (which is possible in majority > of cases). > I'll release it shortly and will give an additional notice > > @Ulisses > Yes, that's been missing in the released version. I'll add it shortly. > Working on a patch, should be available by monday. You can always fork & > add it, we love patches! > > @Cesar > I haven't planned to do any dynamic payloads, although I'll add a couple > of examples on how I'm doing same thing while parsing Cassandra protocol. > Since their types are dynamic (for instance, string type consists of long > and sequence of ASCII chars), I do have some version remotely resembling > what you mention. Although since I haven't yet found an elegant way, I can > only provide a hint on how to implement it. Will provide docs for that > together with the rest of patches in work. > > > > > On Wed, Dec 4, 2013 at 3:58 PM, Rob Day wrote: > >> On 29 November 2013 22:15, Alex P wrote: >> > Buffy [1] is a Clojure library to work with Binary Data, write complete >> > binary protocol implementations >> > in clojure, store your complex data structures in an off-heap chache, >> read >> > binary files and do >> > everything you would usually do `ByteBuffer`. >> >> Is there any plan to support bit-fields? My main interest at present >> is the Diameter protocol, where some individual bits in the header are >> true/false flags - Gloss decodes that nicely into a sequence of bools, >> but I can't see similar support in Buffy. >> >> -- >> -- >> 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. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > > -- > alex p > -- alex p -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: graphs library?
In ClojureWerkz[1], there're some projects, for example, Titan[2]. Zach Maril [3] is taking care of them, mostly. [1] http://clojurewerkz.org [2] https://github.com/clojurewerkz/titanium [3] https://twitter.com/zackmaril On Mon, Dec 2, 2013 at 3:01 PM, Paweł Rozynek wrote: > hello > > quick question: is there any good graphs related library? the one that > implements data structures and search/traverse or some other algorithms in > a nice fashion. googling found me nothing useful for my simple needs, neo4j > client libs at best. > > thanks for responses > PR > > -- > -- > 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. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- alex p -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Function to Generate EDN :readers Map for Namespace Records?
Instead of trying to do it that way, how about just a thin layer of macrology around defrecord? Within the def-record-reader firm you have access to all the info you need for each reader, without extensive code-walking etc -- -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.